From c3fe855a92502eee55d64eaf9f06f1bb305d29f4 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 23 Apr 2024 19:04:35 +0100 Subject: [PATCH 1/3] Fix interrupt function not being cleared on succesful completion --- .../Scheduler/DataBrokerProtectionProcessor.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift index 0ba21a21f7..4536b76084 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift @@ -72,6 +72,7 @@ final class DataBrokerProtectionProcessor { priorityDate: nil, showWebView: showWebView) { errors in os_log("Scans done", log: .dataBrokerProtection) + self.currentlyRunningOperationsForFunction = nil completion?(errors) self.calculateMisMatches() } @@ -90,6 +91,7 @@ final class DataBrokerProtectionProcessor { priorityDate: nil, showWebView: showWebView) { errors in os_log("Optouts done", log: .dataBrokerProtection) + self.currentlyRunningOperationsForFunction = nil completion?(errors) } } @@ -102,6 +104,7 @@ final class DataBrokerProtectionProcessor { priorityDate: Date(), showWebView: showWebView) { errors in os_log("Queued operations done", log: .dataBrokerProtection) + self.currentlyRunningOperationsForFunction = nil completion?(errors) } } @@ -114,6 +117,7 @@ final class DataBrokerProtectionProcessor { priorityDate: nil, showWebView: showWebView) { errors in os_log("Queued operations done", log: .dataBrokerProtection) + self.currentlyRunningOperationsForFunction = nil completion?(errors) } } From 83754f7650a7e299a8671724e2b3cfda885105a8 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 24 Apr 2024 11:57:01 +0100 Subject: [PATCH 2/3] Cherry pick changes --- .../DataBrokerProtectionProcessor.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift index 4536b76084..01df6e5e39 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift @@ -70,11 +70,11 @@ final class DataBrokerProtectionProcessor { currentlyRunningOperationsForFunction = .runAllScanOperations(pendingCompletion: completion) runOperations(operationType: .scan, priorityDate: nil, - showWebView: showWebView) { errors in + showWebView: showWebView) { [weak self] errors in os_log("Scans done", log: .dataBrokerProtection) - self.currentlyRunningOperationsForFunction = nil + self?.currentlyRunningOperationsForFunction = nil completion?(errors) - self.calculateMisMatches() + self?.calculateMisMatches() } } @@ -89,9 +89,9 @@ final class DataBrokerProtectionProcessor { currentlyRunningOperationsForFunction = .runAllOptOutOperations(pendingCompletion: completion) runOperations(operationType: .optOut, priorityDate: nil, - showWebView: showWebView) { errors in + showWebView: showWebView) { [weak self] errors in os_log("Optouts done", log: .dataBrokerProtection) - self.currentlyRunningOperationsForFunction = nil + self?.currentlyRunningOperationsForFunction = nil completion?(errors) } } @@ -102,9 +102,9 @@ final class DataBrokerProtectionProcessor { currentlyRunningOperationsForFunction = .runQueuedOperations(pendingCompletion: completion) runOperations(operationType: .all, priorityDate: Date(), - showWebView: showWebView) { errors in + showWebView: showWebView) { [weak self] errors in os_log("Queued operations done", log: .dataBrokerProtection) - self.currentlyRunningOperationsForFunction = nil + self?.currentlyRunningOperationsForFunction = nil completion?(errors) } } @@ -115,9 +115,9 @@ final class DataBrokerProtectionProcessor { currentlyRunningOperationsForFunction = .runAllOperations(pendingCompletion: completion) runOperations(operationType: .all, priorityDate: nil, - showWebView: showWebView) { errors in + showWebView: showWebView) { [weak self] errors in os_log("Queued operations done", log: .dataBrokerProtection) - self.currentlyRunningOperationsForFunction = nil + self?.currentlyRunningOperationsForFunction = nil completion?(errors) } } From f66b9572299e2df6e0f96c1b9896e936bad992c5 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 23 Apr 2024 12:41:55 +0100 Subject: [PATCH 3/3] Stop first scan completed notification being sent if there's an error --- .../Scheduler/DataBrokerProtectionScheduler.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionScheduler.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionScheduler.swift index d5f9083d07..0a0f529a9f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionScheduler.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionScheduler.swift @@ -261,7 +261,9 @@ public final class DefaultDataBrokerProtectionScheduler: DataBrokerProtectionSch self.startScheduler(showWebView: showWebView) - self.userNotificationService.sendFirstScanCompletedNotification() + if errors?.oneTimeError == nil { + self.userNotificationService.sendFirstScanCompletedNotification() + } if let hasMatches = try? self.dataManager.hasMatches(), hasMatches {