diff options
Diffstat (limited to 'Rune/App/RuneApp.swift')
| -rw-r--r-- | Rune/App/RuneApp.swift | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Rune/App/RuneApp.swift b/Rune/App/RuneApp.swift index 8c63dd6..1709532 100644 --- a/Rune/App/RuneApp.swift +++ b/Rune/App/RuneApp.swift @@ -50,23 +50,30 @@ private struct RootView: View { } .task { await settingsViewModel.bootstrap() + await syncAuthenticatedState() } - .task(id: settingsViewModel.isAuthenticated) { - guard let client = settingsViewModel.client else { - domainViewModel.reset() - tokenViewModel.reset() - selectedTab = 0 - return + .onChange(of: settingsViewModel.client) { _, _ in + Task { + await syncAuthenticatedState() } - - await domainViewModel.loadDomains(client: client) - await tokenViewModel.loadTokens(client: client) } .fullScreenCover(isPresented: onboardingBinding) { OnboardingView(viewModel: settingsViewModel) } } + private func syncAuthenticatedState() async { + guard let client = settingsViewModel.client else { + domainViewModel.reset() + tokenViewModel.reset() + selectedTab = 0 + return + } + + await domainViewModel.loadDomains(client: client) + await tokenViewModel.loadTokens(client: client) + } + private var onboardingBinding: Binding<Bool> { Binding( get: { settingsViewModel.requiresOnboarding }, |
