From 57e5eca0f98a1ce20fa0f8ab8936dfb772dfe43a Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 26 Jan 2021 22:47:16 -0500 Subject: [PATCH] Implemented bulk notification schedueling after restore. --- ProjectClock/Account.swift | 3 +++ ProjectClock/AddAlarmViewController.swift | 4 ++-- ProjectClock/DebugViewController.swift | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ProjectClock/Account.swift b/ProjectClock/Account.swift index 4237bd5..6924bee 100644 --- a/ProjectClock/Account.swift +++ b/ProjectClock/Account.swift @@ -199,6 +199,9 @@ class ManageVC: UIViewController // Update UI AlarmViewController.staticTable?.reloadData() + // Schedule any missing notifications + Notification.bulkScheduleNotifications(alarms: Alarms.fromLocal().list) + self.msg("Success!", "You're restored your backup.") } } diff --git a/ProjectClock/AddAlarmViewController.swift b/ProjectClock/AddAlarmViewController.swift index 472c131..e9ca42d 100644 --- a/ProjectClock/AddAlarmViewController.swift +++ b/ProjectClock/AddAlarmViewController.swift @@ -156,9 +156,9 @@ class AddAlarmViewController: UIViewController //Schedules notification for the alarm if editFlag{ - Notification(alarm: oldAlarm!).removeNotification() + Notification.removeNotification(alarm: oldAlarm!) } - Notification(alarm: alarm).scheduleNotification() + Notification.scheduleNotification(alarm: alarm) // Dismiss this view self.dismiss(animated: true, completion: nil) diff --git a/ProjectClock/DebugViewController.swift b/ProjectClock/DebugViewController.swift index 825db9b..bde165a 100644 --- a/ProjectClock/DebugViewController.swift +++ b/ProjectClock/DebugViewController.swift @@ -30,7 +30,7 @@ class DebugViewController: UIViewController //Sends a test notification @IBAction func sendNotification(_ sender: Any) { - Notification(alarm: Alarms.fromLocal().listEnabled[0]).scheduleNotification() + Notification.scheduleNotification(alarm: Alarms.fromLocal().listEnabled[0]) } @IBAction func addAlarm(_ sender: Any) @@ -39,7 +39,7 @@ class DebugViewController: UIViewController let alarm = Alarm(hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[1], repeats: [true, true, true, true, true, true, true], lastActivate: Date().added(.minute, -1)) Alarms.fromLocal().apply { $0.list.append(alarm) }.localSave() - Notification(alarm: alarm).scheduleNotification() + Notification.scheduleNotification(alarm: alarm) } @IBAction func deleteAlarm(_ sender: Any)