Skip to content

Commit 73f30d3

Browse files
authored
Fix notifications and retry for bolus errors (#458)
1 parent dfe6ad7 commit 73f30d3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Loop/Managers/DeviceDataManager.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,18 @@ extension DeviceDataManager {
683683
pumpManager.enactBolus(units: units, automatic: automatic) { (error) in
684684
if let error = error {
685685
self.log.error("%{public}@", String(describing: error))
686-
if case .uncertainDelivery = error, !automatic {
687-
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: Date())
686+
687+
switch error {
688+
case .uncertainDelivery:
689+
// Do not generate notification on uncertain delivery error
690+
break
691+
default:
692+
// Do not generate notifications for automatic boluses that fail.
693+
if !automatic {
694+
NotificationManager.sendBolusFailureNotification(for: error, units: units, at: Date())
695+
}
688696
}
697+
689698
self.loopManager.bolusRequestFailed(error) {
690699
completion(error)
691700
}

Loop/Managers/LoopAppManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ extension LoopAppManager: UNUserNotificationCenterDelegate {
417417
deviceDataManager?.analyticsServicesManager.didRetryBolus()
418418

419419
deviceDataManager?.enactBolus(units: units, automatic: false) { (_) in
420-
completionHandler()
420+
DispatchQueue.main.async {
421+
completionHandler()
422+
}
421423
}
422424
return
423425
}

Loop/Managers/WatchDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ final class WatchDataManager: NSObject {
366366
return
367367
}
368368

369-
deviceManager.enactBolus(units: bolus.value, automatic: true) { (error) in
369+
deviceManager.enactBolus(units: bolus.value, automatic: false) { (error) in
370370
if error == nil {
371371
self.deviceManager.analyticsServicesManager.didSetBolusFromWatch(bolus.value)
372372
}

0 commit comments

Comments
 (0)