File tree Expand file tree Collapse file tree
app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/nav Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,19 +67,16 @@ 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- 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- }
70+
71+ applyMutation {
72+ // Only attach a navEvent if we are actually changing the destination compared to what was set during initialization.
73+ val shouldNav = newRoute != startDestination || loggedIn != isLoggedIn
74+
75+ copy(
76+ isLoggedIn = loggedIn,
77+ startDestination = newRoute,
78+ navEvent = if (shouldNav) UIEvent (newRoute) else navEvent
79+ )
8380 }
8481 }
8582 }
You can’t perform that action at this time.
0 commit comments