Просмотр исходного кода

Fix initialization of Bolus Display Threshold setting #1020

Deniz Cengiz 1 месяц назад
Родитель
Сommit
754e7f83ae

+ 1 - 0
Trio/Resources/json/defaults/freeaps/freeaps_settings.json

@@ -33,6 +33,7 @@
   "xGridLines" : true,
   "yGridLines" : true,
   "rulerMarks" : true,
+  "bolusDisplayThreshold": 0.01,
   "forecastDisplayType": "cone",
   "maxCarbs": 250,
   "maxFat": 250,

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

@@ -1,6 +1,6 @@
 import Foundation
 
-enum BolusDisplayThreshold: Decimal, CaseIterable, Encodable, Identifiable {
+enum BolusDisplayThreshold: Decimal, JSON, CaseIterable, Identifiable, Codable, Hashable {
     public var id: Decimal { rawValue }
     case oneUnit = 1
     case halfUnit = 0.5

+ 4 - 0
Trio/Sources/Models/TrioSettings.swift

@@ -249,6 +249,10 @@ extension TrioSettings: Decodable {
             settings.rulerMarks = rulerMarks
         }
 
+        if let bolusDisplayThreshold = try? container.decode(BolusDisplayThreshold.self, forKey: .bolusDisplayThreshold) {
+            settings.bolusDisplayThreshold = bolusDisplayThreshold
+        }
+
         if let forecastDisplayType = try? container.decode(ForecastDisplayType.self, forKey: .forecastDisplayType) {
             settings.forecastDisplayType = forecastDisplayType
         }