Skip to content

Commit 3f5b148

Browse files
committed
Recompute insulin effect if insulinEffectStartDate is earlier than last computation
1 parent 655f7e1 commit 3f5b148

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Loop/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>NFCReaderUsageDescription</key>
6-
<string>The app uses NFC to pair with diabetes devices.</string>
75
<key>AppGroupIdentifier</key>
86
<string>$(APP_GROUP_IDENTIFIER)</string>
97
<key>AppStoreURL</key>
@@ -57,6 +55,8 @@
5755
<true/>
5856
<key>LoopLocalCacheDurationDays</key>
5957
<string>$(LOOP_LOCAL_CACHE_DURATION_DAYS)</string>
58+
<key>NFCReaderUsageDescription</key>
59+
<string>The app uses NFC to pair with diabetes devices.</string>
6060
<key>NSBluetoothAlwaysUsageDescription</key>
6161
<string>The app needs to use Bluetooth to send and receive data from your diabetes devices.</string>
6262
<key>NSBluetoothPeripheralUsageDescription</key>

Loop/Managers/LoopDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ extension LoopDataManager {
999999
}
10001000
}
10011001

1002-
if insulinEffect == nil {
1002+
if insulinEffect == nil || insulinEffect?.first?.startDate ?? .distantFuture > insulinEffectStartDate {
10031003
self.logger.debug("Recomputing insulin effects")
10041004
updateGroup.enter()
10051005
doseStore.getGlucoseEffects(start: insulinEffectStartDate, end: nil, basalDosingEnd: now()) { (result) -> Void in

Loop/View Controllers/RootNavigationController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RootNavigationController: UINavigationController {
2222
case .carbEntry:
2323
statusTableViewController.presentCarbEntryScreen(nil)
2424
case .preMeal:
25-
statusTableViewController.presentPreMealMode()
25+
statusTableViewController.togglePreMealMode()
2626
case .bolus:
2727
statusTableViewController.presentBolusScreen()
2828
case .customPresets:

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
14691469
}
14701470

14711471
private func createPreMealButtonItem(selected: Bool, isEnabled: Bool) -> UIBarButtonItem {
1472-
let item = UIBarButtonItem(image: UIImage.preMealImage(selected: selected), style: .plain, target: self, action: #selector(togglePreMealMode(_:)))
1472+
let item = UIBarButtonItem(image: UIImage.preMealImage(selected: selected), style: .plain, target: self, action: #selector(premealButtonTapped(_:)))
14731473
item.accessibilityLabel = NSLocalizedString("Pre-Meal Targets", comment: "The label of the pre-meal mode toggle button")
14741474

14751475
if selected {
@@ -1545,8 +1545,12 @@ final class StatusTableViewController: LoopChartsTableViewController {
15451545

15461546
present(vc, animated: true, completion: nil)
15471547
}
1548+
1549+
@IBAction func premealButtonTapped(_ sender: UIBarButtonItem) {
1550+
togglePreMealMode(confirm: false)
1551+
}
15481552

1549-
@IBAction func togglePreMealMode(_ sender: UIBarButtonItem) {
1553+
func togglePreMealMode(confirm: Bool = true) {
15501554
if preMealMode == true {
15511555
if confirm {
15521556
let alert = UIAlertController(title: "Disable Pre-Meal Preset?", message: "This will remove any currently applied pre-meal preset.", preferredStyle: .alert)
@@ -1592,10 +1596,6 @@ final class StatusTableViewController: LoopChartsTableViewController {
15921596
present(vc, animated: true, completion: nil)
15931597
}
15941598

1595-
@IBAction func togglePreMealMode(_ sender: UIBarButtonItem) {
1596-
presentPreMealMode(confirm: false)
1597-
}
1598-
15991599
func presentCustomPresets(confirm: Bool = true) {
16001600
if workoutMode == true {
16011601
if confirm {

0 commit comments

Comments
 (0)