Procházet zdrojové kódy

a manual bolus limited by maxBolus

Ivan Valkou před 5 roky
rodič
revize
e67c5e3202

+ 1 - 0
FreeAPS/Sources/Modules/Bolus/BolusDataFlow.swift

@@ -4,4 +4,5 @@ enum Bolus {
 
 protocol BolusProvider: Provider {
     var suggestion: Suggestion? { get }
+    func pumpSettings() -> PumpSettings
 }

+ 6 - 0
FreeAPS/Sources/Modules/Bolus/BolusProvider.swift

@@ -3,5 +3,11 @@ extension Bolus {
         var suggestion: Suggestion? {
             storage.retrieve(OpenAPS.Enact.suggested, as: Suggestion.self)
         }
+
+        func pumpSettings() -> PumpSettings {
+            storage.retrieve(OpenAPS.Settings.settings, as: PumpSettings.self)
+                ?? PumpSettings(from: OpenAPS.defaults(for: OpenAPS.Settings.settings))
+                ?? PumpSettings(insulinActionCurve: 5, maxBolus: 10, maxBasal: 2)
+        }
     }
 }

+ 4 - 1
FreeAPS/Sources/Modules/Bolus/BolusViewModel.swift

@@ -38,9 +38,12 @@ extension Bolus {
                 showModal(for: nil)
                 return
             }
+
+            let maxAmount = Double(max(amount, provider.pumpSettings().maxBolus))
+
             unlockmanager.unlock()
                 .sink { _ in } receiveValue: {
-                    self.apsManager.enactBolus(amount: Double(self.amount), isSMB: false)
+                    self.apsManager.enactBolus(amount: maxAmount, isSMB: false)
                     self.showModal(for: nil)
                 }
                 .store(in: &lifetime)

+ 1 - 1
FreeAPS/Sources/Services/UnlockManager/UnlockManager.swift

@@ -23,7 +23,7 @@ final class BaseUnlockManager: UnlockManager {
                 }
             }
 
-            let reason = "We need to unlock your data."
+            let reason = "We need to make sure you are the owner of the device."
 
             if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
                 context.evaluatePolicy(