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 | |
| 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')
| -rw-r--r-- | Hutch/App/AppState.swift | 15 | ||||
| -rw-r--r-- | Hutch/App/DeepLink.swift | 4 | ||||
| -rw-r--r-- | Hutch/App/RootView.swift | 7 |
3 files changed, 26 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() diff --git a/Hutch/App/DeepLink.swift b/Hutch/App/DeepLink.swift index a4b8269..e42bd6b 100644 --- a/Hutch/App/DeepLink.swift +++ b/Hutch/App/DeepLink.swift @@ -2,6 +2,7 @@ import Foundation /// Represents a parsed `hutch://` deep link. enum DeepLink: Equatable { + case home /// hutch://git/<owner>/<repo> case repository(owner: String, repo: String) /// hutch://todo/<owner>/<tracker>/<ticketId> @@ -19,6 +20,9 @@ enum DeepLink: Equatable { let components = url.pathComponents(fromScheme: "hutch") switch components.first { + case "home", nil: + self = .home + case "git" where components.count >= 3: let owner = components[1] let repo = components[2] diff --git a/Hutch/App/RootView.swift b/Hutch/App/RootView.swift index 9c4e71a..8d4eef1 100644 --- a/Hutch/App/RootView.swift +++ b/Hutch/App/RootView.swift @@ -161,6 +161,10 @@ struct RootView: View { guard appState.isAuthenticated else { return } switch link { + case .home: + homePath = NavigationPath() + appState.selectedTab = .home + case .repository(let owner, let repo): resolveRepositoryLink(owner: owner, repo: repo) @@ -284,12 +288,15 @@ private struct MoreNavigationRoot: View { thread: thread, onViewed: { InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) }, onMarkRead: { InboxReadStateStore.markViewed(max(Date(), thread.lastActivityAt), for: thread.id) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: -1) }, onMarkUnread: { InboxReadStateStore.markUnread(for: thread.id) + NeedsAttentionSnapshotStore.adjustUnreadInboxThreads(by: 1) } ) } |
