Skip to content

Commit d666489

Browse files
committed
Put missed meals notifications behind feature flag
1 parent 733b3ee commit d666489

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

Common/FeatureFlags.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct FeatureFlagConfiguration: Decodable {
3838
let dynamicCarbAbsorptionEnabled: Bool
3939
let adultChildInsulinModelSelectionEnabled: Bool
4040
let profileExpirationSettingsViewEnabled: Bool
41+
let missedMealNotifications: Bool
4142

4243

4344
fileprivate init() {
@@ -220,6 +221,14 @@ struct FeatureFlagConfiguration: Decodable {
220221
#else
221222
self.profileExpirationSettingsViewEnabled = true
222223
#endif
224+
225+
// Missed meal notifications compiler flag is inverse, since the default state is enabled.
226+
#if MISSED_MEAL_NOTIFICATIONS_DISABLED
227+
self.missedMealNotifications = false
228+
#else
229+
self.missedMealNotifications = true
230+
#endif
231+
223232
}
224233
}
225234

@@ -253,7 +262,8 @@ extension FeatureFlagConfiguration : CustomDebugStringConvertible {
253262
"* usePositiveMomentumAndRCForManualBoluses: \(usePositiveMomentumAndRCForManualBoluses)",
254263
"* dynamicCarbAbsorptionEnabled: \(dynamicCarbAbsorptionEnabled)",
255264
"* adultChildInsulinModelSelectionEnabled: \(adultChildInsulinModelSelectionEnabled)",
256-
"* profileExpirationSettingsViewEnabled: \(profileExpirationSettingsViewEnabled)"
265+
"* profileExpirationSettingsViewEnabled: \(profileExpirationSettingsViewEnabled)",
266+
"* missedMealNotifications: \(missedMealNotifications)"
257267
].joined(separator: "\n")
258268
}
259269
}

Loop/Managers/LoopDataManager.swift

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -874,26 +874,28 @@ extension LoopDataManager {
874874
logger.default("Loop ended")
875875
notify(forChange: .loopFinished)
876876

877-
let carbEffectStart = now().addingTimeInterval(-MissedMealSettings.maxRecency)
878-
carbStore.getGlucoseEffects(start: carbEffectStart, end: now(), effectVelocities: insulinCounteractionEffects) {[weak self] result in
879-
guard
880-
let self = self,
881-
case .success((_, let carbEffects)) = result
882-
else {
883-
if case .failure(let error) = result {
884-
self?.logger.error("Failed to fetch glucose effects to check for missed meal: %{public}@", String(describing: error))
877+
if FeatureFlags.missedMealNotifications {
878+
let carbEffectStart = now().addingTimeInterval(-MissedMealSettings.maxRecency)
879+
carbStore.getGlucoseEffects(start: carbEffectStart, end: now(), effectVelocities: insulinCounteractionEffects) {[weak self] result in
880+
guard
881+
let self = self,
882+
case .success((_, let carbEffects)) = result
883+
else {
884+
if case .failure(let error) = result {
885+
self?.logger.error("Failed to fetch glucose effects to check for missed meal: %{public}@", String(describing: error))
886+
}
887+
return
885888
}
886-
return
889+
890+
self.mealDetectionManager.generateMissedMealNotificationIfNeeded(
891+
insulinCounteractionEffects: self.insulinCounteractionEffects,
892+
carbEffects: carbEffects,
893+
pendingAutobolusUnits: self.recommendedAutomaticDose?.recommendation.bolusUnits,
894+
bolusDurationEstimator: { [unowned self] bolusAmount in
895+
return self.delegate?.loopDataManager(self, estimateBolusDuration: bolusAmount)
896+
}
897+
)
887898
}
888-
889-
self.mealDetectionManager.generateMissedMealNotificationIfNeeded(
890-
insulinCounteractionEffects: self.insulinCounteractionEffects,
891-
carbEffects: carbEffects,
892-
pendingAutobolusUnits: self.recommendedAutomaticDose?.recommendation.bolusUnits,
893-
bolusDurationEstimator: { [unowned self] bolusAmount in
894-
return self.delegate?.loopDataManager(self, estimateBolusDuration: bolusAmount)
895-
}
896-
)
897899
}
898900

899901
// 5 second delay to allow stores to cache data before it is read by widget

Loop/Views/AlertManagementView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ struct AlertManagementView: View {
6666
if FeatureFlags.criticalAlertsEnabled {
6767
muteAlertsSection
6868
}
69-
missedMealAlertSection
69+
if FeatureFlags.missedMealNotifications {
70+
missedMealAlertSection
71+
}
7072
}
7173
.navigationTitle(NSLocalizedString("Alert Management", comment: "Title of alert management screen"))
7274
}

0 commit comments

Comments
 (0)