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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user