Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1198,11 +1198,17 @@ extension DeviceDataManager: PumpManagerDelegate {
setLastError(error: error)
}

func pumpManager(_ pumpManager: PumpManager, hasNewPumpEvents events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: Error?) -> Void) {
func pumpManager(
_ pumpManager: PumpManager,
hasNewPumpEvents events: [NewPumpEvent],
lastReconciliation: Date?,
replacePendingEvents: Bool,
completion: @escaping (_ error: Error?) -> Void)
{
dispatchPrecondition(condition: .onQueue(queue))
log.default("PumpManager:%{public}@ hasNewPumpEvents (lastReconciliation = %{public}@)", String(describing: type(of: pumpManager)), String(describing: lastReconciliation))

loopManager.addPumpEvents(events, lastReconciliation: lastReconciliation) { (error) in
doseStore.addPumpEvents(events, lastReconciliation: lastReconciliation, replacePendingEvents: replacePendingEvents) { (error) in
if let error = error {
self.log.error("Failed to addPumpEvents to DoseStore: %{public}@", String(describing: error))
}
Expand Down
20 changes: 0 additions & 20 deletions Loop/Managers/LoopDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -741,26 +741,6 @@ extension LoopDataManager {
}
}


/// Adds and stores new pump events
///
/// - Parameters:
/// - events: The pump events to add
/// - completion: A closure called once upon completion
/// - 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.
/// - error: An error explaining why the events could not be saved.
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void) {
doseStore.addPumpEvents(events, lastReconciliation: lastReconciliation) { (error) in
completion(error)

self.dataAccessQueue.async {
if error == nil {
self.clearCachedInsulinEffects()
}
}
}
}

/// Logs a new external bolus insulin dose in the DoseStore and HealthKit
///
/// - Parameters:
Expand Down
4 changes: 2 additions & 2 deletions Loop/Managers/Store Protocols/DoseStoreProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protocol DoseStoreProtocol: AnyObject {
var pumpEventQueryAfterDate: Date { get }

// MARK: dose management
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void)
func addPumpEvents(_ events: [NewPumpEvent], lastReconciliation: Date?, replacePendingEvents: Bool, completion: @escaping (_ error: DoseStore.DoseStoreError?) -> Void)

func addReservoirValue(_ unitVolume: Double, at date: Date, completion: @escaping (_ value: ReservoirValue?, _ previousValue: ReservoirValue?, _ areStoredValuesContinuous: Bool, _ error: DoseStore.DoseStoreError?) -> Void)

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