Fix: tapping task notification now marks it complete

Tap body → marks complete + navigates to tasks.
Swipe action 'Mark Complete' → marks complete without opening app.
TaskViewModel.reload() called on foreground to sync UserDefaults changes
made while app was backgrounded.

Co-Authored-By: Kutesir <tqwyy79vzn@privaterelay.appleid.com>
This commit is contained in:
Robin Kutesa
2026-06-01 03:52:10 +03:00
parent 12e3cfdd13
commit 0c48ca888b
3 changed files with 66 additions and 11 deletions

View File

@@ -72,6 +72,13 @@ class TaskViewModel: ObservableObject {
}
}
func reload() {
guard let data = UserDefaults.standard.data(forKey: persistKey),
let saved = try? JSONDecoder().decode([TaskItem].self, from: data)
else { return }
tasks = saved
}
private func save() {
if let data = try? JSONEncoder().encode(tasks) {
UserDefaults.standard.set(data, forKey: persistKey)