Skip to content

Commit b4f0432

Browse files
authored
Merge pull request #252 from tidepool-org/ps2/LOOP-1750/alert-display-on-restart
Fix display of uncertain delivery alert on app restart
2 parents b80ec44 + fb4b045 commit b4f0432

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

Loop/Managers/DeliveryUncertaintyAlertManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class DeliveryUncertaintyAlertManager {
3939
self.showUncertainDeliveryRecoveryView()
4040
}
4141
alert.addAction(action)
42-
self.rootViewController.dismiss(animated: true)
43-
self.rootViewController.present(alert, animated: animated)
42+
self.rootViewController.dismiss(animated: false) {
43+
self.rootViewController.present(alert, animated: animated)
44+
}
4445
self.uncertainDeliveryAlert = alert
4546
}
4647
}

Loop/Managers/DeviceDataManager.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,14 @@ final class DeviceDataManager {
376376
return Manager.init(rawState: rawState) as? CGMManagerUI
377377
}
378378

379+
func checkDeliveryUncertaintyState() {
380+
if let pumpManager = pumpManager, pumpManager.status.deliveryIsUncertain {
381+
DispatchQueue.main.async {
382+
self.deliveryUncertaintyAlertManager!.showAlert()
383+
}
384+
}
385+
}
386+
379387
// Get HealthKit authorization for all of the stores
380388
func authorize(_ completion: @escaping () -> Void) {
381389
// Authorize all types at once for simplicity
@@ -483,12 +491,6 @@ private extension DeviceDataManager {
483491
soundVendor: pumpManager)
484492

485493
deliveryUncertaintyAlertManager = DeliveryUncertaintyAlertManager(pumpManager: pumpManager, rootViewController: rootViewController)
486-
487-
if pumpManager.status.deliveryIsUncertain {
488-
DispatchQueue.main.async {
489-
self.deliveryUncertaintyAlertManager!.showAlert()
490-
}
491-
}
492494
}
493495
}
494496

@@ -711,11 +713,13 @@ extension DeviceDataManager: PumpManagerDelegate {
711713
// Update the pump-schedule based settings
712714
loopManager.setScheduleTimeZone(status.timeZone)
713715

714-
DispatchQueue.main.async {
715-
if status.deliveryIsUncertain {
716-
self.deliveryUncertaintyAlertManager?.showAlert()
717-
} else {
718-
self.deliveryUncertaintyAlertManager?.clearAlert()
716+
if status.deliveryIsUncertain != oldStatus.deliveryIsUncertain {
717+
DispatchQueue.main.async {
718+
if status.deliveryIsUncertain {
719+
self.deliveryUncertaintyAlertManager?.showAlert()
720+
} else {
721+
self.deliveryUncertaintyAlertManager?.clearAlert()
722+
}
719723
}
720724
}
721725
}

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ final class StatusTableViewController: LoopChartsTableViewController {
157157
onscreen = true
158158

159159
deviceManager.analyticsServicesManager.didDisplayStatusScreen()
160+
161+
deviceManager.checkDeliveryUncertaintyState()
160162
}
161163

162164
override func viewWillDisappear(_ animated: Bool) {

0 commit comments

Comments
 (0)