summaryrefslogtreecommitdiff
path: root/Hutch/App/AppState.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-11 19:47:40 -0500
committerChristian Cleberg <[email protected]>2026-04-11 19:47:40 -0500
commit61164b6dd8343c8699d091dd5fccc55beb0b90b9 (patch)
tree0a2befeb986966d42062802e2a29d795be907fee /Hutch/App/AppState.swift
parent27bfcbbed6acde158ec40c5bb46e45e76c81a319 (diff)
downloadhutch-2.11.0.tar.gz
hutch-2.11.0.tar.bz2
hutch-2.11.0.zip
feat: add contribution calendar to user profilesv2.11.0
Add a trailing 365-day contribution heatmap to user profile views, backed by HutchStatsService. Includes calendar model, view model, SwiftUI calendar view, app configuration, and unit tests.
Diffstat (limited to 'Hutch/App/AppState.swift')
-rw-r--r--Hutch/App/AppState.swift7
1 files changed, 7 insertions, 0 deletions
diff --git a/Hutch/App/AppState.swift b/Hutch/App/AppState.swift
index 8613dc8..c519adc 100644
--- a/Hutch/App/AppState.swift
+++ b/Hutch/App/AppState.swift
@@ -56,6 +56,7 @@ final class AppState {
// MARK: - Networking
let client: SRHTClient
+ let configuration: AppConfiguration
// MARK: - Deep link pending navigation
@@ -67,6 +68,7 @@ final class AppState {
// MARK: - Init
init() {
+ self.configuration = AppConfiguration()
let token = KeychainHelper.loadToken()
self.client = SRHTClient(token: token)
}
@@ -107,11 +109,13 @@ final class AppState {
accounts = storedAccounts
activeAccountID = target.id
currentUser = user
+ ContributionWidgetContextStore.saveActor(user.canonicalName)
authPhase = .authenticated
await refreshNeedsAttentionSnapshot()
} catch {
client.setToken(nil)
currentUser = nil
+ ContributionWidgetContextStore.clear()
authPhase = .unauthenticated
NeedsAttentionSnapshotStore.clear()
}
@@ -131,6 +135,7 @@ final class AppState {
UserDefaults.standard.set(entry.id, forKey: AppStorageKeys.activeAccountID)
try KeychainHelper.saveAccounts(accounts)
currentUser = user
+ ContributionWidgetContextStore.saveActor(user.canonicalName)
authPhase = .authenticated
await refreshNeedsAttentionSnapshot()
} catch {
@@ -168,6 +173,7 @@ final class AppState {
let user = try await fetchMe()
currentUser = user
+ ContributionWidgetContextStore.saveActor(user.canonicalName)
authPhase = .authenticated
await refreshNeedsAttentionSnapshot()
}
@@ -355,6 +361,7 @@ final class AppState {
activeAccountID = ""
UserDefaults.standard.removeObject(forKey: AppStorageKeys.activeAccountID)
currentUser = nil
+ ContributionWidgetContextStore.clear()
pendingDeepLink = nil
pendingTabNavigation = nil
deepLinkError = nil