summaryrefslogtreecommitdiff
path: root/Shared/NeedsAttentionSnapshot.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/NeedsAttentionSnapshot.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/NeedsAttentionSnapshot.swift')
-rw-r--r--Shared/NeedsAttentionSnapshot.swift21
1 files changed, 13 insertions, 8 deletions
diff --git a/Shared/NeedsAttentionSnapshot.swift b/Shared/NeedsAttentionSnapshot.swift
index d4c581c..5f584c3 100644
--- a/Shared/NeedsAttentionSnapshot.swift
+++ b/Shared/NeedsAttentionSnapshot.swift
@@ -58,11 +58,11 @@ enum NeedsAttentionSnapshotStore {
private static let snapshotKey = "needsAttention.snapshot"
static func load(
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) -> NeedsAttentionSnapshot? {
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
}
@@ -71,7 +71,7 @@ enum NeedsAttentionSnapshotStore {
static func save(
_ snapshot: NeedsAttentionSnapshot,
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) {
guard let defaults,
@@ -79,7 +79,7 @@ enum NeedsAttentionSnapshotStore {
return
}
- defaults.set(data, forKey: scopedKey(for: accountID))
+ defaults.set(data, forKey: scopedKey(for: resolvedAccountID(accountID, defaults: defaults)))
reloadWidgetTimelines()
}
@@ -87,7 +87,7 @@ enum NeedsAttentionSnapshotStore {
unreadInboxThreads: Int? = nil,
assignedOpenTickets: Int? = nil,
failedBuilds: Int? = nil,
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) {
let existing = load(accountID: accountID, defaults: defaults)
@@ -102,7 +102,7 @@ enum NeedsAttentionSnapshotStore {
static func adjustUnreadInboxThreads(
by delta: Int,
- accountID: String? = ActiveAccountContextStore.load(),
+ accountID: String? = nil,
defaults: UserDefaults? = sharedDefaults()
) {
guard let existing = load(accountID: accountID, defaults: defaults),
@@ -123,10 +123,11 @@ enum NeedsAttentionSnapshotStore {
}
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()
}
@@ -139,6 +140,10 @@ enum NeedsAttentionSnapshotStore {
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: NeedsAttentionWidgetConfiguration.kind)