Skip to content

Commit 188468a

Browse files
fixed duplicate back stack entry
1 parent 22114fe commit 188468a

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/nav/RootNavigationViewModel.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,19 @@ class RootNavigationViewModel @Inject constructor(
6767
val hasSkipped = userInfoRepository.getSkipFromDataStore()
6868
val shouldShowHome = loggedIn || hasSkipped || !ONBOARDING_FLAG
6969
val newRoute = if (shouldShowHome) UpliftRootRoute.Home else UpliftRootRoute.Onboarding
70-
applyMutation {
71-
copy(
72-
startDestination = newRoute,
73-
navEvent = UIEvent(newRoute)
74-
)
70+
if (newRoute != uiStateFlow.value.startDestination || loggedIn != uiStateFlow.value.isLoggedIn) {
71+
applyMutation {
72+
copy(
73+
isLoggedIn = loggedIn,
74+
startDestination = newRoute,
75+
navEvent = UIEvent(newRoute)
76+
)
77+
}
78+
}
79+
else {
80+
applyMutation {
81+
copy(isLoggedIn = loggedIn)
82+
}
7583
}
7684
}
7785
}

0 commit comments

Comments
 (0)