Refactor and remove isStartDestinationSameWithNextDestination

pull/1470/head
anhtuannd 1 year ago
parent 4739f4d541
commit 13468631d6

@ -143,10 +143,10 @@ class NiaAppState(
trace("Navigation: ${topLevelDestination.name}") { trace("Navigation: ${topLevelDestination.name}") {
val topLevelNavOptions = navOptions { val topLevelNavOptions = navOptions {
val startDestination = navController.graph.findStartDestination() val startDestination = navController.graph.findStartDestination()
// Avoid popUpTo and navigate to same screen. // Avoid popUpTo and navigate to same screen.
val shouldNotSavedAndRestored = isStartDestinationSameWithNextDestination( val shouldNotSavedAndRestored = startDestination.hasRoute(topLevelDestination.route)
startDestination, topLevelDestination
) ?: false
// Pop up to the start destination of the graph to // Pop up to the start destination of the graph to
// avoid building up a large stack of destinations // avoid building up a large stack of destinations
// on the back stack as users select items // on the back stack as users select items
@ -168,14 +168,6 @@ class NiaAppState(
} }
} }
/**
* Check if next destination is same with start destination of current graph.
*/
private fun isStartDestinationSameWithNextDestination(
startDestination: NavDestination,
nextDestination: TopLevelDestination,
): Boolean? = startDestination.hasRoute(nextDestination.route)
fun navigateToSearch() = navController.navigateToSearch() fun navigateToSearch() = navController.navigateToSearch()
} }

Loading…
Cancel
Save