+ Extend low reservoir notification range + Prevent negative duration doses, which can happen if the phone clock is changed + Fixes Loop crash when changing time back and cancelling bolus, Loop Issue #2057
@@ -117,7 +117,9 @@ public struct UnfinalizedDose: RawRepresentable, Equatable, CustomStringConverti
let programmedUnits = units
self.programmedUnits = programmedUnits
- let newDuration = date.timeIntervalSince(startTime)
+
+ // Guard against negative duration if clock has changed
+ let newDuration = max(0, date.timeIntervalSince(startTime))
switch doseType {
case .bolus:
@@ -93,7 +93,7 @@ public struct Pod {
public static let defaultLowReservoirReminder: Double = 10
// Allowed Low Reservoir reminder values
- public static let allowedLowReservoirReminderValues = Array(stride(from: 10, through: 50, by: 1))
+ public static let allowedLowReservoirReminderValues = Array(stride(from: 1, through: 50, by: 1))
}
// DeliveryStatus used in StatusResponse and DetailedStatus
@@ -147,7 +147,9 @@ public struct UnfinalizedDose: RawRepresentable, Equatable, CustomStringConverti
scheduledUnits = units
@@ -95,7 +95,7 @@ public struct Pod {