Explorar o código

Merge branch 'dev' of github.com:nightscout/Trio-dev into auto-vesion-action

Deniz Cengiz hai 1 ano
pai
achega
fee1140557

+ 1 - 1
Config.xcconfig

@@ -1,5 +1,5 @@
 APP_DISPLAY_NAME = Trio
-APP_VERSION = 0.4.0
+APP_VERSION = 0.4.1
 APP_BUILD_NUMBER = 1
 COPYRIGHT_NOTICE =
 DEVELOPER_TEAM = ##TEAM_ID##

+ 1 - 1
Trio/Resources/json/defaults/preferences.json

@@ -38,7 +38,7 @@
   "insulinPeakTime" : 75,
   "carbsReqThreshold" : 1,
   "noisyCGMTargetMultiplier" : 1.3,
-  "suspend_zeros_iob" : false,
+  "suspend_zeros_iob" : true,
   "maxDelta_bg_threshold" : 0.2,
   "adjustmentFactor" : 0.8,
   "adjustmentFactorSigmoid" : 0.5,

+ 5 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -59670,6 +59670,7 @@
     },
     "Clear temporary basal rates and reset IOB when suspended." : {
       "comment" : "Mini Hint for Suspend Zeros IOB",
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -152321,6 +152322,7 @@
       }
     },
     "Note: Applies only to pumps with on-pump suspend options." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -195773,6 +195775,7 @@
     },
     "Suspend Zeros IOB" : {
       "comment" : "Suspend Zeros IOB",
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -210214,6 +210217,7 @@
       }
     },
     "This prevents lingering insulin effects when your pump is suspended, ensuring safer management of insulin on board." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -235442,6 +235446,7 @@
       }
     },
     "When Suspend Zeros IOB is enabled, any active temporary basal rates during a pump suspension are reset, with new 0 U/hr temporary basal rates added to counteract those done during suspension." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {

+ 1 - 1
Trio/Sources/Models/Preferences.swift

@@ -39,7 +39,7 @@ struct Preferences: JSON, Equatable {
     var insulinPeakTime: Decimal = 75
     var carbsReqThreshold: Decimal = 1.0
     var noisyCGMTargetMultiplier: Decimal = 1.3
-    var suspendZerosIOB: Bool = false
+    var suspendZerosIOB: Bool = true
     var timestamp: Date?
     var maxDeltaBGthreshold: Decimal = 0.2
     var adjustmentFactor: Decimal = 0.8

+ 0 - 3
Trio/Sources/Modules/AlgorithmAdvancedSettings/AlgorithmAdvancedSettingsStateModel.swift

@@ -16,7 +16,6 @@ extension AlgorithmAdvancedSettings {
         @Published var insulinPeakTime: Decimal = 75
         @Published var skipNeutralTemps: Bool = false
         @Published var unsuspendIfNoTemp: Bool = false
-        @Published var suspendZerosIOB: Bool = false
         @Published var min5mCarbimpact: Decimal = 8
         @Published var remainingCarbsFraction: Decimal = 1.0
         @Published var remainingCarbsCap: Decimal = 90
@@ -40,8 +39,6 @@ extension AlgorithmAdvancedSettings {
             subscribePreferencesSetting(\.insulinPeakTime, on: $insulinPeakTime) { insulinPeakTime = $0 }
             subscribePreferencesSetting(\.skipNeutralTemps, on: $skipNeutralTemps) { skipNeutralTemps = $0 }
             subscribePreferencesSetting(\.unsuspendIfNoTemp, on: $unsuspendIfNoTemp) { unsuspendIfNoTemp = $0 }
-            subscribePreferencesSetting(\.suspendZerosIOB, on: $suspendZerosIOB) { suspendZerosIOB = $0 }
-            subscribePreferencesSetting(\.suspendZerosIOB, on: $suspendZerosIOB) { suspendZerosIOB = $0 }
             subscribePreferencesSetting(\.min5mCarbimpact, on: $min5mCarbimpact) { min5mCarbimpact = $0 }
             subscribePreferencesSetting(\.remainingCarbsFraction, on: $remainingCarbsFraction) { remainingCarbsFraction = $0 }
             subscribePreferencesSetting(\.remainingCarbsCap, on: $remainingCarbsCap) { remainingCarbsCap = $0 }

+ 0 - 31
Trio/Sources/Modules/AlgorithmAdvancedSettings/View/AlgorithmAdvancedSettingsRootView.swift

@@ -220,37 +220,6 @@ extension AlgorithmAdvancedSettings {
                 )
 
                 SettingInputSection(
-                    decimalValue: $decimalPlaceholder,
-                    booleanValue: $state.suspendZerosIOB,
-                    shouldDisplayHint: $shouldDisplayHint,
-                    selectedVerboseHint: Binding(
-                        get: { selectedVerboseHint },
-                        set: {
-                            selectedVerboseHint = $0.map { AnyView($0) }
-                            hintLabel = String(localized: "Suspend Zeros IOB", comment: "Suspend Zeros IOB")
-                        }
-                    ),
-                    units: state.units,
-                    type: .boolean,
-                    label: String(localized: "Suspend Zeros IOB", comment: "Suspend Zeros IOB"),
-                    miniHint: String(
-                        localized: "Clear temporary basal rates and reset IOB when suspended.",
-                        comment: "Mini Hint for Suspend Zeros IOB"
-                    ),
-                    verboseHint:
-                    VStack(alignment: .leading, spacing: 10) {
-                        Text("Default: OFF").bold()
-                        Text(
-                            "When Suspend Zeros IOB is enabled, any active temporary basal rates during a pump suspension are reset, with new 0 U/hr temporary basal rates added to counteract those done during suspension."
-                        )
-                        Text(
-                            "This prevents lingering insulin effects when your pump is suspended, ensuring safer management of insulin on board."
-                        )
-                        Text("Note: Applies only to pumps with on-pump suspend options.")
-                    }
-                )
-
-                SettingInputSection(
                     decimalValue: $state.smbDeliveryRatio,
                     booleanValue: $booleanPlaceholder,
                     shouldDisplayHint: $shouldDisplayHint,

+ 18 - 3
Trio/Sources/Modules/Onboarding/OnboardingStateModel.swift

@@ -25,13 +25,23 @@ extension Onboarding {
 
         // MARK: - App Diagnostics
 
-        var diagnosticsSharingOption: DiagnosticsSharingOption {
-            get { (PropertyPersistentFlags.shared.diagnosticsSharingEnabled ?? true) ? .enabled : .disabled }
-            set { PropertyPersistentFlags.shared.diagnosticsSharingEnabled = (newValue == .enabled) }
+        private var persistedDiagnosticsSharing: Bool? {
+            get { PropertyPersistentFlags.shared.diagnosticsSharingEnabled }
+            set { PropertyPersistentFlags.shared.diagnosticsSharingEnabled = newValue }
         }
 
+        var diagnosticsSharingOption: DiagnosticsSharingOption = .enabled
         var hasAcceptedPrivacyPolicy: Bool = false
 
+        func syncDiagnosticsOptionFromStorage() {
+            diagnosticsSharingOption = (persistedDiagnosticsSharing ?? true) ? .enabled : .disabled
+        }
+
+        func updateDiagnosticsOption(to option: DiagnosticsSharingOption) {
+            diagnosticsSharingOption = option
+            persistedDiagnosticsSharing = (option == .enabled)
+        }
+
         // MARK: - Determine Initial Build State
 
         /// Determines whether the app is in a fresh install state for Trio v0.3.0.
@@ -729,6 +739,11 @@ extension Onboarding {
             preferences.resistanceLowersTarget = resistanceLowersTarget
             preferences.halfBasalExerciseTarget = halfBasalTarget
 
+            // default suspendZeroesIOB to true
+            if !preferences.suspendZerosIOB {
+                preferences.suspendZerosIOB = true
+            }
+
             settingsManager.preferences = preferences
         }
 

+ 4 - 1
Trio/Sources/Modules/Onboarding/View/OnboardingSteps/DiagnosticsStepView.swift

@@ -14,7 +14,7 @@ struct DiagnosticsStepView: View {
 
             ForEach(DiagnosticsSharingOption.allCases, id: \.self) { option in
                 Button(action: {
-                    state.diagnosticsSharingOption = option
+                    state.updateDiagnosticsOption(to: option)
                 }) {
                     HStack {
                         Image(systemName: state.diagnosticsSharingOption == option ? "largecircle.fill.circle" : "circle")
@@ -83,6 +83,9 @@ struct DiagnosticsStepView: View {
             .font(.footnote)
             .foregroundStyle(Color.secondary)
         }
+        .onAppear {
+            state.syncDiagnosticsOptionFromStorage()
+        }
         .sheet(isPresented: $shouldDisplayPrivacyPolicy) {
             PrivacyPolicyView()
         }

+ 15 - 1
Trio/Sources/Services/Network/Nightscout/NightscoutManager.swift

@@ -84,6 +84,8 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
     private var coreDataPublisher: AnyPublisher<Set<NSManagedObjectID>, Never>?
     private var subscriptions = Set<AnyCancellable>()
 
+    private let debouncedQueue = DispatchQueue(label: "OrefDeterminationDebounce", qos: .utility)
+
     init(resolver: Resolver) {
         injectServices(resolver)
         subscribe()
@@ -131,7 +133,19 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
         /// 2. To not spam the user's NS site with a high number of uploads in a very short amount of time (less than 1sec)
         coreDataPublisher?
             .filteredByEntityName("OrefDetermination")
-            .debounce(for: .seconds(2), scheduler: DispatchQueue.global(qos: .background))
+            .handleEvents(receiveOutput: { _ in
+                debug(
+                    .nightscout,
+                    "OrefDetermination update"
+                )
+            })
+            .debounce(for: .seconds(2), scheduler: debouncedQueue)
+            .handleEvents(receiveOutput: { _ in
+                debug(
+                    .nightscout,
+                    "OrefDetermination update debounceed"
+                )
+            })
             .sink { [weak self] objectIDs in
                 guard let self = self else { return }