diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/components/MainScaffold.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/components/MainScaffold.kt index f0cb1dcd8..b063606ca 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/components/MainScaffold.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/components/MainScaffold.kt @@ -113,11 +113,17 @@ private fun NavHostController.navigateToSelectedItem(destination: MainNavigation } // Avoid multiple copies of the same destination when re-selecting the same item launchSingleTop = true + // Restore state when re-selecting a previously selected item - val currentBackStackEntry = this@navigateToSelectedItem.currentBackStackEntry - val hasDeepLink = currentBackStackEntry?.arguments?.parcelableExtra(NavController.KEY_DEEP_LINK_INTENT) != null - val isNavigatingToStartDestination = startDestination.route == destination::class.qualifiedName - restoreState = !hasDeepLink || !isNavigatingToStartDestination + restoreState = true + + // The commented code below was supposed to be an improvement on the line above, + // but it doesn't behave the way we'd like. TODO: Find a better solution that works + + // val currentBackStackEntry = this@navigateToSelectedItem.currentBackStackEntry + // val hasDeepLink = currentBackStackEntry?.arguments?.parcelableExtra(NavController.KEY_DEEP_LINK_INTENT) != null + // val isNavigatingToStartDestination = startDestination.route == destination::class.qualifiedName + // restoreState = !hasDeepLink || !isNavigatingToStartDestination } }