fix nav routing

This commit is contained in:
greenart7c3
2024-04-19 12:07:53 -03:00
parent 42d6ab1440
commit cd203e0644
@@ -499,7 +499,7 @@ fun MainScreen(
var showDialog by remember { mutableStateOf(false) }
if (BuildConfig.FLAVOR != "offline") {
LaunchedEffect(Unit, route.value) {
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
askNotificationPermission(
context,
@@ -508,12 +508,6 @@ fun MainScreen(
showDialog = true
}
}
launch(Dispatchers.Main) {
if (route.value != null) {
navController.navigate(route.value!!)
route.value = null
}
}
}
}
@@ -660,9 +654,22 @@ fun MainScreen(
}
}
) { padding ->
var localRoute by remember { mutableStateOf(route.value ?: Route.Home.route) }
if (BuildConfig.FLAVOR != "offline") {
LaunchedEffect(Unit, route.value) {
launch(Dispatchers.Main) {
if (route.value != null) {
localRoute = route.value!!
route.value = null
}
}
}
}
NavHost(
navController,
startDestination = route.value ?: Route.Home.route,
startDestination = localRoute,
enterTransition = { fadeIn(animationSpec = tween(200)) },
exitTransition = { fadeOut(animationSpec = tween(200)) }
) {