diff options
| author | Christian Cleberg <[email protected]> | 2026-03-24 18:28:21 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-24 18:28:21 -0500 |
| commit | 94d0b581bbd2be7b63c07fe7f86d736daa96e1f9 (patch) | |
| tree | e0fb93129ab426c2ebdabd2ea3a84b713f843656 /Hutch/App/AppState.swift | |
| parent | 28c5b36bed9e3a4217415079827f657205a080f7 (diff) | |
| download | hutch-2.4.0.tar.gz hutch-2.4.0.tar.bz2 hutch-2.4.0.zip | |
v2.4.0: widgetsv2.4.0
Diffstat (limited to 'Hutch/App/AppState.swift')
| -rw-r--r-- | Hutch/App/AppState.swift | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Hutch/App/AppState.swift b/Hutch/App/AppState.swift index e74a58b..9788c85 100644 --- a/Hutch/App/AppState.swift +++ b/Hutch/App/AppState.swift @@ -77,11 +77,13 @@ final class AppState { let user = try await fetchMe() currentUser = user authPhase = .authenticated + await refreshNeedsAttentionSnapshot() } catch { try? KeychainHelper.deleteToken() client.setToken(nil) currentUser = nil authPhase = .unauthenticated + NeedsAttentionSnapshotStore.clear() } } @@ -98,6 +100,7 @@ final class AppState { try KeychainHelper.saveToken(token) currentUser = user authPhase = .authenticated + await refreshNeedsAttentionSnapshot() } catch { // Roll back — don't leave an invalid token in the client. client.setToken(nil) @@ -111,6 +114,7 @@ final class AppState { HTTPCookieStorage.shared.cookies?.forEach { HTTPCookieStorage.shared.deleteCookie($0) } await clearWebData() clearWebContentRenderCaches() + NeedsAttentionSnapshotStore.clear() authPhase = .unauthenticated selectedTab = .home } @@ -125,6 +129,7 @@ final class AppState { HTTPCookieStorage.shared.cookies?.forEach { HTTPCookieStorage.shared.deleteCookie($0) } await clearWebData() clearWebContentRenderCaches() + NeedsAttentionSnapshotStore.clear() authPhase = .unauthenticated selectedTab = .home @@ -270,6 +275,16 @@ final class AppState { selectedTab = .home } + private func refreshNeedsAttentionSnapshot() async { + guard let currentUser else { + NeedsAttentionSnapshotStore.clear() + return + } + + let viewModel = HomeViewModel(currentUser: currentUser, client: client) + await viewModel.loadDashboard() + } + private func clearWebData() async { await withCheckedContinuation { continuation in let dataTypes = WKWebsiteDataStore.allWebsiteDataTypes() |
