Преглед изворни кода

Fall back to G7 sensorEndsAt during grace period so bobble matches arc

The home bobble's remaining-time tag derives from
`HomeStateModel.cgmSensorExpiresAt`, which for G7 was always
`sensorExpiresAt` (lifetime end at +10 d). Once the sensor enters
grace period that timestamp is in the past, the formatter clamps to
zero and the tag collapses to "<1m" while the arc — driven by
`cgmLifecycleProgress` against `sensorEndsAt` — still shows
~12 h of progress remaining.

When `sensorExpiresAt` has passed, fall back to `sensorEndsAt`
(lifetime + grace) so the tag and arc share an end date and the
user sees "8 h 5 m" instead of "<1 m" through grace.
trioneer пре 2 недеља
родитељ
комит
426c500515
1 измењених фајлова са 10 додато и 1 уклоњено
  1. 10 1
      Trio/Sources/Modules/Home/HomeStateModel.swift

+ 10 - 1
Trio/Sources/Modules/Home/HomeStateModel.swift

@@ -704,7 +704,16 @@ extension Home {
                 return sim.simulatedSensorExpiresAt
             }
             guard let manager else { return nil }
-            if let g7 = manager as? G7CGMManager, let exp = g7.sensorExpiresAt { return exp }
+            // Once a G7 enters grace period, `sensorExpiresAt` is in the past
+            // and would collapse the bobble countdown to "<1m" while the arc
+            // (driven by lifecycle.percentComplete against `sensorEndsAt`) is
+            // still mid-progress. Fall back to `sensorEndsAt` so bobble and
+            // arc agree, and the user sees grace-period time remaining.
+            if let g7 = manager as? G7CGMManager {
+                let now = Date()
+                if let exp = g7.sensorExpiresAt, exp > now { return exp }
+                return g7.sensorEndsAt ?? g7.sensorExpiresAt
+            }
             if let g6 = manager as? G6CGMManager, let exp = g6.latestReading?.sessionExpDate { return exp }
             if let g5 = manager as? G5CGMManager, let exp = g5.latestReading?.sessionExpDate { return exp }