Explorar el Código

Fix COB and IOB not being displayed

Deniz Cengiz hace 1 año
padre
commit
9916449ff6

+ 7 - 6
FreeAPS/Sources/Services/ContactTrick/ContactTrickManager.swift

@@ -220,12 +220,13 @@ final class BaseContactTrickManager: NSObject, ContactTrickManager, Injectable {
 
 
         state.lastLoopDate = lastDetermination?.timestamp
         state.lastLoopDate = lastDetermination?.timestamp
 
 
-        state.iob = lastDetermination?.iob as? Decimal
-        if let cobValue = lastDetermination?.cob {
-            state.cob = Decimal(cobValue)
-        } else {
-            state.cob = 0
-        }
+        let iobValue = lastDetermination?.iob as? Decimal ?? 0.0
+        state.iob = iobValue
+        state.iobText = Formatter.decimalFormatterWithOneFractionDigit.string(from: iobValue as NSNumber)
+
+        let cobValue = lastDetermination?.cob as? Decimal ?? 0.0
+        state.cob = cobValue
+        state.cobText = Formatter.integerFormatter.string(from: cobValue as NSNumber)
 
 
         if let eventualBG = settingsManager.settings.units == .mgdL ? lastDetermination?
         if let eventualBG = settingsManager.settings.units == .mgdL ? lastDetermination?
             .eventualBG : lastDetermination?
             .eventualBG : lastDetermination?