diff --git a/app/src/main/kotlin/com/flixclusive/mobile/MobileApp.kt b/app/src/main/kotlin/com/flixclusive/mobile/MobileApp.kt index c787466eb..23be1a2d0 100644 --- a/app/src/main/kotlin/com/flixclusive/mobile/MobileApp.kt +++ b/app/src/main/kotlin/com/flixclusive/mobile/MobileApp.kt @@ -39,9 +39,10 @@ import com.flixclusive.model.provider.SourceDataState import com.flixclusive.util.AppNavHost import com.flixclusive.util.currentScreenAsState import com.flixclusive.util.navigateIfResumed -import com.flixclusive.util.navigateSingleTopTo import com.ramcosta.composedestinations.dynamic.within +import com.ramcosta.composedestinations.navigation.navigate import com.ramcosta.composedestinations.utils.currentDestinationFlow +import com.ramcosta.composedestinations.utils.startDestination import kotlinx.coroutines.launch import kotlin.system.exitProcess import com.flixclusive.core.util.R as UtilR @@ -141,10 +142,18 @@ internal fun MobileActivity.MobileApp( navController.run { val isPoppingToRoot = screen == currentNavGraph - navigateSingleTopTo( - direction = screen, - isPoppingToRoot = isPoppingToRoot - ) + navigate(screen) { + if (isPoppingToRoot) { + popUpTo(screen.startRoute.route) + } else { + popUpTo(MobileNavGraphs.home.startDestination.route) { + saveState = true + } + } + + launchSingleTop = true + restoreState = true + } } } ) diff --git a/app/src/main/kotlin/com/flixclusive/util/NavigationHelper.kt b/app/src/main/kotlin/com/flixclusive/util/NavigationHelper.kt index cdded2571..9fdbd367a 100644 --- a/app/src/main/kotlin/com/flixclusive/util/NavigationHelper.kt +++ b/app/src/main/kotlin/com/flixclusive/util/NavigationHelper.kt @@ -18,7 +18,6 @@ import androidx.navigation.NavController import androidx.navigation.NavDestination import androidx.navigation.NavDestination.Companion.hierarchy import androidx.navigation.NavGraph -import androidx.navigation.NavGraph.Companion.findStartDestination import androidx.navigation.NavHostController import androidx.navigation.NavOptionsBuilder import com.flixclusive.ROOT @@ -37,22 +36,6 @@ import com.ramcosta.composedestinations.navigation.navigate import com.ramcosta.composedestinations.spec.Direction import com.ramcosta.composedestinations.spec.NavGraphSpec -internal fun NavHostController.navigateSingleTopTo( - direction: NavGraphSpec, - isPoppingToRoot: Boolean = false, -) = navigate(direction) { - if (isPoppingToRoot) { - popUpTo(direction.startRoute.route) - } else { - popUpTo(graph.findStartDestination().id) { - saveState = true - } - } - - launchSingleTop = true - restoreState = true -} - private fun NavBackStackEntry.lifecycleIsResumed() = lifecycle.currentState == Lifecycle.State.RESUMED