summaryrefslogtreecommitdiff
path: root/Hutch/Views/Home
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Views/Home')
-rw-r--r--Hutch/Views/Home/HomePinStore.swift15
1 files changed, 15 insertions, 0 deletions
diff --git a/Hutch/Views/Home/HomePinStore.swift b/Hutch/Views/Home/HomePinStore.swift
index e9bffd1..3b00843 100644
--- a/Hutch/Views/Home/HomePinStore.swift
+++ b/Hutch/Views/Home/HomePinStore.swift
@@ -144,6 +144,21 @@ enum HomePinStore {
saveAll(pinsByUser, defaults: defaults)
}
+ static func removePin(
+ id: String,
+ for userKey: String,
+ defaults: UserDefaults = .standard
+ ) {
+ let normalizedUserKey = normalizedUserKey(userKey)
+ guard !normalizedUserKey.isEmpty else { return }
+
+ var pinsByUser = loadAll(defaults: defaults)
+ var pins = normalizedPins(pinsByUser[normalizedUserKey] ?? loadPins(for: normalizedUserKey, defaults: defaults))
+ pins.removeAll { $0.id == id }
+ pinsByUser[normalizedUserKey] = pins
+ saveAll(pinsByUser, defaults: defaults)
+ }
+
static func pinnedProjectIDs(
for userKey: String,
defaults: UserDefaults = .standard