mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
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:
1 parent
23bb2a75cc
commit
4b3c6342b1
1 file changed
+4
-1
@@ -70,6 +70,9 @@ private fun AppContent() {
|
|||||||
|
|
||||||
LaunchedEffect(navController) { graph.navigator.attach(navController) }
|
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 session by graph.repository.session.collectAsState()
|
||||||
val currentEntry by navController.currentBackStackEntryAsState()
|
val currentEntry by navController.currentBackStackEntryAsState()
|
||||||
val onLogin = currentEntry?.destination?.hasRoute(Route.Login::class) == true
|
val onLogin = currentEntry?.destination?.hasRoute(Route.Login::class) == true
|
||||||
@@ -84,7 +87,7 @@ private fun AppContent() {
|
|||||||
|
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = navController,
|
navController = navController,
|
||||||
startDestination = Route.Home,
|
startDestination = startDestination,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
composable<Route.Login> { LoginRoute() }
|
composable<Route.Login> { LoginRoute() }
|
||||||
|
|||||||
Reference in new issue
Block a user