55: Only navigate when not on the current screen r=msfjarvis a=msfjarvis

bors r+

Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
bors[bot] 2020-10-29 12:10:19 +00:00 committed by GitHub
commit b641cab624
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,12 +71,11 @@ fun LobstersApp(
label = { Text(stringResource(id = screen.labelRes)) },
selected = currentRoute == screen.route,
onClick = {
// This is the equivalent to popUpTo the start destination
navController.popBackStack(navController.graph.startDestination, false)
// This if check gives us a "singleTop" behavior where we do not create a
// second instance of the composable if we are already on that destination
if (currentRoute != screen.route) {
// This is the equivalent to popUpTo the start destination
navController.popBackStack(navController.graph.startDestination, false)
navController.navigate(screen.route)
}
}