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

Fix COB and IOB not being displayed

Deniz Cengiz 1 год назад
Родитель
Сommit
9916449ff6
1 измененных файлов с 7 добавлено и 6 удалено
  1. 7 6
      FreeAPS/Sources/Services/ContactTrick/ContactTrickManager.swift

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

@@ -220,12 +220,13 @@ final class BaseContactTrickManager: NSObject, ContactTrickManager, Injectable {
 
         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?
             .eventualBG : lastDetermination?