diff options
| author | Christian Cleberg <[email protected]> | 2026-08-07 01:44:17 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-08-07 01:44:17 -0500 |
| commit | a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8 (patch) | |
| tree | 6124f8e184a5ba3b648f173af597928caa5fcd84 /Hutch/Views/Home/RecentActivityStore.swift | |
| parent | 5e4e259d8bfd9b062aa39af793ec3a59b70ad7f0 (diff) | |
| download | hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.tar.gz hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.tar.bz2 hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.zip | |
Let users clear recent activity on Home (#11)
Add a Clear button in the Home Recent section header to drop all
entries, plus swipe-to-delete on each row to forget a single item
(gated on the existing swipe-actions setting). Back it with
RecentActivityStore.clear and remove(id:), with unit tests.
Diffstat (limited to 'Hutch/Views/Home/RecentActivityStore.swift')
| -rw-r--r-- | Hutch/Views/Home/RecentActivityStore.swift | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Hutch/Views/Home/RecentActivityStore.swift b/Hutch/Views/Home/RecentActivityStore.swift index 464a2c1..6bc5720 100644 --- a/Hutch/Views/Home/RecentActivityStore.swift +++ b/Hutch/Views/Home/RecentActivityStore.swift @@ -129,6 +129,16 @@ enum RecentActivityStore { ) } + static func remove(id: String, defaults: UserDefaults) { + var entries = load(defaults: defaults) + entries.removeAll { $0.id == id } + save(entries, defaults: defaults) + } + + static func clear(defaults: UserDefaults) { + defaults.removeObject(forKey: AppStorageKeys.recentActivity) + } + private static func record(_ entry: RecentActivityEntry, defaults: UserDefaults) { var entries = load(defaults: defaults) entries.removeAll { $0.id == entry.id } |
