Skip to content

Commit 5baebff

Browse files
committed
[LOOP-4685] favorite foods feature flag; UserDefaults
1 parent 4a8ae67 commit 5baebff

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

Common/FeatureFlags.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ extension FeatureFlagConfiguration : CustomDebugStringConvertible {
266266
"* adultChildInsulinModelSelectionEnabled: \(adultChildInsulinModelSelectionEnabled)",
267267
"* profileExpirationSettingsViewEnabled: \(profileExpirationSettingsViewEnabled)",
268268
"* missedMealNotifications: \(missedMealNotifications)",
269-
"* allowAlgorithmExperiments: \(allowAlgorithmExperiments)"
269+
"* allowAlgorithmExperiments: \(allowAlgorithmExperiments)",
270+
"* allowExperimentalFeatures: \(allowExperimentalFeatures)"
270271
].joined(separator: "\n")
271272
}
272273
}
@@ -290,6 +291,20 @@ extension FeatureFlagConfiguration {
290291
#endif
291292
}
292293

294+
var allowExperimentalFeatures: Bool {
295+
#if EXPERIMENTAL_FEATURES_ENABLED
296+
return true
297+
#elseif EXPERIMENTAL_FEATURES_ENABLED_CONDITIONALLY
298+
if debugEnabled {
299+
return true
300+
} else {
301+
return UserDefaults.appGroup?.allowExperimentalFeatures ?? false
302+
}
303+
#else
304+
return false
305+
#endif
306+
}
307+
293308
var allowSimulators: Bool {
294309
#if SIMULATORS_ENABLED
295310
return true

Loop/Views/CarbEntryView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct CarbEntryView: View, HorizontalSizeClassOverride {
7171

7272
continueActionButton
7373

74-
if isNewEntry {
74+
if isNewEntry, FeatureFlags.allowExperimentalFeatures {
7575
favoriteFoodsCard
7676
}
7777

Loop/Views/SettingsView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public struct SettingsView: View {
5656
configurationSection
5757
}
5858
deviceSettingsSection
59-
favoriteFoodsSection
59+
if FeatureFlags.allowExperimentalFeatures {
60+
favoriteFoodsSection
61+
}
6062
if (viewModel.pumpManagerSettingsViewModel.isTestingDevice || viewModel.cgmManagerSettingsViewModel.isTestingDevice) && viewModel.showDeleteTestData {
6163
deleteDataSection
6264
}

LoopCore/NSUserDefaults.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extension UserDefaults {
1919
case bedtime = "com.loopkit.Loop.bedtime"
2020
case lastProfileExpirationAlertDate = "com.loopkit.Loop.lastProfileExpirationAlertDate"
2121
case allowDebugFeatures = "com.loopkit.Loop.allowDebugFeatures"
22+
case allowExperimentalFeatures = "com.loopkit.Loop.allowExperimentalFeatures"
2223
case allowSimulators = "com.loopkit.Loop.allowSimulators"
2324
case LastMissedMealNotification = "com.loopkit.Loop.lastMissedMealNotification"
2425
case userRequestedLoopReset = "com.loopkit.Loop.userRequestedLoopReset"
@@ -148,6 +149,10 @@ extension UserDefaults {
148149
}
149150
}
150151

152+
public var allowExperimentalFeatures: Bool {
153+
return bool(forKey: Key.allowExperimentalFeatures.rawValue)
154+
}
155+
151156
public var allowSimulators: Bool {
152157
return bool(forKey: Key.allowSimulators.rawValue)
153158
}

0 commit comments

Comments
 (0)