Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snackbar shown again on popBackstack() #961

Open
kosavsech opened this issue Jul 1, 2023 · 1 comment
Open

Snackbar shown again on popBackstack() #961

kosavsech opened this issue Jul 1, 2023 · 1 comment

Comments

@kosavsech
Copy link

kosavsech commented Jul 1, 2023

// Check if there's a userMessage to show to the user
val currentOnUserMessageDisplayed by rememberUpdatedState(onUserMessageDisplayed)
LaunchedEffect(userMessage) {
if (userMessage != 0) {
viewModel.showEditResultMessage(userMessage)
currentOnUserMessageDisplayed()
}
}

This part of code being legitimately trigger by
onTaskUpdate = {
navActions.navigateToTasks(
if (taskId == null) ADD_EDIT_RESULT_OK else EDIT_RESULT_OK
)
},
or
onDeleteTask = { navActions.navigateToTasks(DELETE_RESULT_OK) }

But after you can go to task details again and click go back arrow in top bar.
topBar = {
TaskDetailTopAppBar(onBack = onBack, onDelete = viewModel::deleteTask)
},

Last snackbar message will be shown again. But this time, in my opinion, because there is copy of route with USER_MESSAGE_ARG in backstack.

How this can be fixed or bypassed?

@CodPro-Sui
Copy link

override fun onDestroyView() {
super.onDestroyView()
// Dismiss the Snackbar if it's currently shown
snackbar?.dismiss()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants