fix(folio-app): branch start destination on initial session

Read repository.session.value at first composition and pick
Route.Home or Route.Login as the NavHost startDestination. Avoids
the one-frame Home flash on cold start with no persisted session.
This commit is contained in:
pj committed 2026-04-26 22:19:26 +07:00
1 parent 23bb2a75cc
commit 4b3c6342b1
1 file changed
+4 -1
@@ -70,6 +70,9 @@ private fun AppContent() {
LaunchedEffect(navController) { graph.navigator.attach(navController) }
val initialSession = remember { graph.repository.session.value }
val startDestination: Route = if (initialSession != null) Route.Home else Route.Login
val session by graph.repository.session.collectAsState()
val currentEntry by navController.currentBackStackEntryAsState()
val onLogin = currentEntry?.destination?.hasRoute(Route.Login::class) == true
@@ -84,7 +87,7 @@ private fun AppContent() {
NavHost(
navController = navController,
startDestination = Route.Home,
startDestination = startDestination,
modifier = Modifier.fillMaxSize(),
) {
composable<Route.Login> { LoginRoute() }