routing working i think? good enough getting things in place

This commit is contained in:
talksik
2021-12-19 19:18:46 -08:00
parent c8b383449e
commit 1cca80166f
3 changed files with 27 additions and 25 deletions
+14 -15
View File
@@ -30,25 +30,24 @@ struct RouterView: View {
@EnvironmentObject var navigationStack: NavigationStack
var body: some View {
SplashView()
.onReceive(self.authSessionStore.$user) {updatedUserFromAuth in // observing user because takes longer to get the user details than see updates to sessionstate and we need the user for the logic below
print("figuring out where to send the user based on state: \(self.authSessionStore.sessionState)")
if self.authSessionStore.sessionState == SessionState.isAuthenticated && updatedUserFromAuth != nil {
print("user stored in authsession store: \(updatedUserFromAuth)")
// evaluate where the user should go based on how much data he has
// user is authenticated but has never picked a username or avatar
if updatedUserFromAuth?.nickname != nil && updatedUserFromAuth?.avatar != nil {
self.navigationStack.push(OnboardingTrioView())
// authenticated and have user's data
if self.authSessionStore.sessionState == SessionState.isAuthenticated {
if self.authSessionStore.user != nil {
if self.authSessionStore.user?.nickname == nil && self.authSessionStore.user?.avatar == nil {
OnboardingTrioView()
} else {// user is existing user/up and running user -> signs in is pushed nicely right to hub
self.navigationStack.push(InnerCircleView())
InnerCircleView()
}
} else {
print("sending user to welcome view")
// go to welcome page at which point they can go and follow the programmatic
// line to the sigin and so on and so forth
self.navigationStack.push(WelcomeView())
OnboardingTrioView()
}
} else if self.authSessionStore.sessionState == SessionState.isLoggedOut {
// go to welcome page at which point they can go and follow the programmatic
// line to the sigin and so on and so forth
WelcomeView()
} else {
SplashView()
}
}
}