Skip to content

Commit 710182e

Browse files
authored
Merge pull request #2297 from LoopKit/fix/issue-2267
Force reload from UserDefaults for Algorithm Experiments
2 parents e55ea0c + 2281b5d commit 710182e

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

Loop/Views/GlucoseBasedApplicationFactorSelectionView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public struct GlucoseBasedApplicationFactorSelectionView: View {
4444
}
4545
}
4646
.padding()
47-
.onChange(of: isGlucoseBasedApplicationFactorEnabled) { newValue in
48-
UserDefaults.standard.glucoseBasedApplicationFactorEnabled = newValue
49-
}
5047
}
5148
.navigationBarTitleDisplayMode(.inline)
5249
}

Loop/Views/IntegralRetrospectiveCorrectionSelectionView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ public struct IntegralRetrospectiveCorrectionSelectionView: View {
2727
Divider()
2828

2929
Toggle(NSLocalizedString("Enable Integral Retrospective Correction", comment: "Title for Integral Retrospective Correction toggle"), isOn: $isIntegralRetrospectiveCorrectionEnabled)
30-
.onChange(of: isIntegralRetrospectiveCorrectionEnabled) { newValue in
31-
UserDefaults.standard.integralRetrospectiveCorrectionEnabled = newValue
32-
}
3330
.padding(.top, 20)
3431
}
3532
.padding()

Loop/Views/SettingsView+algorithmExperimentsSection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public struct ExperimentRow: View {
3939
}
4040

4141
public struct ExperimentsSettingsView: View {
42-
@State private var isGlucoseBasedApplicationFactorEnabled = UserDefaults.standard.glucoseBasedApplicationFactorEnabled
43-
@State private var isIntegralRetrospectiveCorrectionEnabled = UserDefaults.standard.integralRetrospectiveCorrectionEnabled
42+
@AppStorage(UserDefaults.Key.GlucoseBasedApplicationFactorEnabled.rawValue) private var isGlucoseBasedApplicationFactorEnabled = false
43+
@AppStorage(UserDefaults.Key.IntegralRetrospectiveCorrectionEnabled.rawValue) private var isIntegralRetrospectiveCorrectionEnabled = false
4444
var automaticDosingStrategy: AutomaticDosingStrategy
4545

4646
public var body: some View {
@@ -80,7 +80,7 @@ public struct ExperimentsSettingsView: View {
8080

8181

8282
extension UserDefaults {
83-
private enum Key: String {
83+
fileprivate enum Key: String {
8484
case GlucoseBasedApplicationFactorEnabled = "com.loopkit.algorithmExperiments.glucoseBasedApplicationFactorEnabled"
8585
case IntegralRetrospectiveCorrectionEnabled = "com.loopkit.algorithmExperiments.integralRetrospectiveCorrectionEnabled"
8686
}

0 commit comments

Comments
 (0)