summaryrefslogtreecommitdiff
path: root/Shared/SystemStatusWidgetSnapshot.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-05-14 13:18:55 -0500
committerChristian Cleberg <[email protected]>2026-05-14 13:27:41 -0500
commit51b2eb0e6296734960f37cebd40fee34a1f261f9 (patch)
tree65063727d8dcff3540818676d7b53288499475dd /Shared/SystemStatusWidgetSnapshot.swift
parent9a853f8777230e0639261b5bc817201ec2d9deca (diff)
downloadhutch-51b2eb0e6296734960f37cebd40fee34a1f261f9.tar.gz
hutch-51b2eb0e6296734960f37cebd40fee34a1f261f9.tar.bz2
hutch-51b2eb0e6296734960f37cebd40fee34a1f261f9.zip
feat: add App Intents for Hutch navigation
- add read-only App Intents for core Hutch workflows - route intents through the existing Hutch navigation/deep-link model - expose Work Queue, Recent Activity, System Status, pinned resources, projects, failed builds, assigned tickets, saved searches, and search where supported - keep App Intents non-mutating for the initial implementation - preserve existing widget, Safari extension, and hutch:// routing behavior References: https://todo.sr.ht/~ccleberg/hutch/71
Diffstat (limited to 'Shared/SystemStatusWidgetSnapshot.swift')
-rw-r--r--Shared/SystemStatusWidgetSnapshot.swift17
1 files changed, 11 insertions, 6 deletions
diff --git a/Shared/SystemStatusWidgetSnapshot.swift b/Shared/SystemStatusWidgetSnapshot.swift
index 0b19365..025e58c 100644
--- a/Shared/SystemStatusWidgetSnapshot.swift
+++ b/Shared/SystemStatusWidgetSnapshot.swift
@@ -34,11 +34,11 @@ enum SystemStatusWidgetSnapshotStore {
private static let snapshotKey = "systemStatus.widgetSnapshot"
static func load(
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) -> SystemStatusWidgetSnapshot? {
guard let defaults,
- let data = defaults.data(forKey: scopedKey(for: accountID)) else {
+ let data = defaults.data(forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults))) else {
return nil
}
return try? JSONDecoder().decode(SystemStatusWidgetSnapshot.self, from: data)
@@ -46,22 +46,23 @@ enum SystemStatusWidgetSnapshotStore {
static func save(
_ snapshot: SystemStatusWidgetSnapshot,
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) {
guard let defaults,
let data = try? JSONEncoder().encode(snapshot) else {
return
}
- defaults.set(data, forKey: scopedKey(for: accountID))
+ defaults.set(data, forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults)))
reloadWidgetTimelines()
}
static func clear(
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) {
- defaults?.removeObject(forKey: scopedKey(for: accountID))
+ guard let defaults else { return }
+ defaults.removeObject(forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults)))
reloadWidgetTimelines()
}
@@ -74,6 +75,10 @@ enum SystemStatusWidgetSnapshotStore {
return "\(snapshotKey).\(accountID)"
}
+ private static func resolvedAccountID(_ accountID: String?, defaults: UserDefaults) -> String? {
+ accountID ?? ActiveAccountContextStore.load(defaults: defaults)
+ }
+
private static func reloadWidgetTimelines() {
#if canImport(WidgetKit)
WidgetCenter.shared.reloadTimelines(ofKind: SystemStatusWidgetConfiguration.kind)