Skip to content

Commit ffbdc46

Browse files
committed
update per requested changes
1 parent b7cd557 commit ffbdc46

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

Loop/Managers/LoopDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ extension LoopDataManager {
11571157
throw LoopError.glucoseTooOld(date: glucose.startDate)
11581158
}
11591159

1160-
guard lastGlucoseDate.timeIntervalSince(now()) <= LoopCoreConstants.inputDataRecencyInterval else {
1160+
guard lastGlucoseDate.timeIntervalSince(now()) <= LoopCoreConstants.futureGlucoseDataInterval else {
11611161
throw LoopError.glucoseInFuture(date: lastGlucoseDate)
11621162
}
11631163

Loop/Models/LoopError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ extension LoopError: LocalizedError {
192192
return String(format: NSLocalizedString("Glucose data is %1$@ old", comment: "The error message when glucose data is too old to be used. (1: glucose data age in minutes)"), minutes)
193193
case .glucoseInFuture(let date):
194194
let minutes = formatter.string(from: -date.timeIntervalSinceNow) ?? ""
195-
return String(format: NSLocalizedString("Glucose data is %1$@ in the future", comment: "The error message when glucose data is in the future to be used. (1: glucose data time in future in minutes)"), minutes)
195+
return String(format: NSLocalizedString("Invalid glucose reading with a timestamp that is %1$@ in the future", comment: "The error message when glucose data is in the future. (1: glucose data time in future in minutes)"), minutes)
196196
case .pumpDataTooOld(let date):
197197
let minutes = formatter.string(from: -date.timeIntervalSinceNow) ?? ""
198198
return String(format: NSLocalizedString("Pump data is %1$@ old", comment: "The error message when pump data is too old to be used. (1: pump data age in minutes)"), minutes)

Loop/View Models/BolusEntryViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ final class BolusEntryViewModel: ObservableObject {
674674
switch error {
675675
case LoopError.missingDataError(.glucose), LoopError.glucoseTooOld:
676676
notice = .staleGlucoseData
677-
case LoopError.missingDataError(.glucose), LoopError.glucoseInFuture:
677+
case LoopError.glucoseInFuture:
678678
notice = .futureGlucoseData
679679
case LoopError.pumpDataTooOld:
680680
notice = .stalePumpData

Loop/Views/BolusEntryView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ struct BolusEntryView: View {
336336
)
337337
case .futureGlucoseData:
338338
return WarningView(
339-
title: Text("Glucose in Future", comment: "Title for bolus screen notice when glucose data is in the future"),
340-
caption: Text("Check for data in the future on phone.", comment: "Caption for bolus screen notice when glucose data is in the future")
339+
title: Text("Invalid Future Glucose", comment: "Title for bolus screen notice when glucose data is in the future"),
340+
caption: Text("Check for device time and/or remove any invalid data from Apple Health.", comment: "Caption for bolus screen notice when glucose data is in the future")
341341
)
342342
case .stalePumpData:
343343
return WarningView(

LoopCore/LoopCoreConstants.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public enum LoopCoreConstants {
1313
/// The amount of time since a given date that input data should be considered valid
1414
public static let inputDataRecencyInterval = TimeInterval(minutes: 15)
1515

16+
/// The amount of time in the future a glucose value should be considered valid
17+
public static let futureGlucoseDataInterval = TimeInterval(minutes: 5)
18+
1619
public static let defaultCarbAbsorptionTimes: CarbStore.DefaultAbsorptionTimes = (fast: .minutes(30), medium: .hours(3), slow: .hours(5))
1720

1821
/// How much historical glucose to include in a dosing decision

0 commit comments

Comments
 (0)