Skip to content

Commit 1922a16

Browse files
committed
Allow calls to hasNewPumpEvents that do not replace all pending doses
1 parent 15f05ac commit 1922a16

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

Loop/Managers/DeviceDataManager.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,11 +1198,17 @@ extension DeviceDataManager: PumpManagerDelegate {
11981198
setLastError(error: error)
11991199
}
12001200

1201-
func pumpManager(_ pumpManager: PumpManager, hasNewPumpEvents events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: Error?) -> Void) {
1201+
func pumpManager(
1202+
_ pumpManager: PumpManager,
1203+
hasNewPumpEvents events: [NewPumpEvent],
1204+
lastReconciliation: Date?,
1205+
replacePendingEvents: Bool,
1206+
completion: @escaping (_ error: Error?) -> Void)
1207+
{
12021208
dispatchPrecondition(condition: .onQueue(queue))
12031209
log.default("PumpManager:%{public}@ hasNewPumpEvents (lastReconciliation = %{public}@)", String(describing: type(of: pumpManager)), String(describing: lastReconciliation))
12041210

1205-
loopManager.addPumpEvents(events, lastReconciliation: lastReconciliation) { (error) in
1211+
doseStore.addPumpEvents(events, lastReconciliation: lastReconciliation, replacePendingEvents: replacePendingEvents) { (error) in
12061212
if let error = error {
12071213
self.log.error("Failed to addPumpEvents to DoseStore: %{public}@", String(describing: error))
12081214
}

Loop/Managers/LoopDataManager.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -741,26 +741,6 @@ extension LoopDataManager {
741741
}
742742
}
743743

744-
745-
/// Adds and stores new pump events
746-
///
747-
/// - Parameters:
748-
/// - events: The pump events to add
749-
/// - completion: A closure called once upon completion
750-
/// - lastReconciliation: The date that pump events were most recently reconciled against recorded pump history. Pump events are assumed to be reflective of delivery up until this point in time. If reservoir values are recorded after this time, they may be used to supplement event based delivery.
751-
/// - error: An error explaining why the events could not be saved.
752-
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void) {
753-
doseStore.addPumpEvents(events, lastReconciliation: lastReconciliation) { (error) in
754-
completion(error)
755-
756-
self.dataAccessQueue.async {
757-
if error == nil {
758-
self.clearCachedInsulinEffects()
759-
}
760-
}
761-
}
762-
}
763-
764744
/// Logs a new external bolus insulin dose in the DoseStore and HealthKit
765745
///
766746
/// - Parameters:

Loop/Managers/Store Protocols/DoseStoreProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protocol DoseStoreProtocol: AnyObject {
3535
var pumpEventQueryAfterDate: Date { get }
3636

3737
// MARK: dose management
38-
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void)
39-
38+
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, replacePendingEvents: Bool, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void)
39+
4040
func addReservoirValue(_ unitVolume: Double, at date: Date, completion: @escaping (_ value: ReservoirValue?, _ previousValue: ReservoirValue?, _ areStoredValuesContinuous: Bool, _ error: DoseStore.DoseStoreError?) -> Void)
4141

4242
func getNormalizedDoseEntries(start: Date, end: Date?, completion: @escaping (_ result: DoseStoreResult<[DoseEntry]>) -> Void)

0 commit comments

Comments
 (0)