Repository navigation
Conversation
- Push an immediate Live Activity update when the custom low/high lines change. TIR/TITR use fixed ranges, so this only applies in custom mode. Thresholds are published through writeThresholds() so the effective range is always used. - Refresh the main stats pie when the range lines or range mode change. - Compare reading colors at mmol/L display precision, so two readings that both display as "3.9" get the same color. Applies to the chart, BG text, contact image and the Live Activity widget. mg/dL is unchanged. - Share the rounding via GlucoseConversion.toDisplayedMmol.
…ndary - Route custom low/high line changes through refreshFromCurrentState instead of a separate hand-built Live Activity push, so the dismissed, enabled and in-flight checks apply and picker bursts are debounced. - Use effectiveThresholds() for the contact image so TIR and TITR modes match the chart, BG text and Live Activity. - Add GlucoseBand.of(_:low:high:mmol:) in Shared and use it for the chart, BG text, contact image, stats pie and the Live Activity widget. A reading on a line is low or high, compared at display precision. - Make the stats pie follow the same boundary rule. - Rename normalizeForColorComparison to normalizeToDisplayPrecision and shorten its comment.
c671619 to
1ba4700
Compare
|
I built the branch locally without problems. Should fix in this PR
Suggestions
For maintainers to decide
|
Replace the function-reference/closure ternary with plain per-value conversions so the compiler can type-check it.
A reading exactly on the low or high line is now in range, matching the international consensus on time in range (70-180 mg/dL, 3.9-10.0 mmol/L). GlucoseBand, and so the chart, BG text, contact image, stats pie and Live Activity widget, use the inclusive rule at display precision. The TIR screen and GRI keep their inclusive bands and published cutoffs but now compare at display precision, so readings that display the same mmol/L value share a band. Alarm thresholds are unchanged.
Address review on the range color change: - Watch app and complications color readings with GlucoseBand at the displayed unit's precision, so a reading on a line is green there too. - RetroSnapshot uses the shared band, so the scrubbed BG text matches the chart dots. - mg/dL values are rounded to whole numbers before comparing, so a line picked in mmol/L (stored as 70.26) behaves like the 70 it displays. TIR and GRI get the same rounding. - The Live Activity threshold subscriber skips the initial value, so launch no longer refreshes twice.
1ba4700 to
f2c545f
Compare
|
Thanks for the review. All four fixes are pushed:
On 5, I'm keeping the inclusive rule, as you suggested, pending #779. The case where the Low alarm equals the low line is on purpose: an alarm threshold is a trigger (it fires at or below its value), while a range line is a boundary, so a green 70 can sound the alarm. If maintainers would rather the two agree, I can change it in #839. On 6, I kept GRI in the user's units, since the GRI paper defines its zones in both (3.9–10.0 mmol/L, 70–180 mg/dL for in range). The exception is 181 mg/dL: at 10.047 mmol/L it shows as 10.0, so it counts as in range in mmol/L. Comparing at the precision the user sees keeps the stats consistent with the number on screen. If maintainers prefer the mg/dL cutoffs for everyone, it's a small change. On 7, I've moved the alarm commit and the picker factor into #839, which builds on this PR. This one now covers only colors and stats. |
|
Updated with the latest |
What this fixes
The app decided "low / in range / high" in several places, each with its own comparison. With custom range lines and mmol/L they could disagree with each other and with the number on screen: two readings that both display "3.9" could get different colors, and the Live Activity and stats pie could be stale after a range change.
Changes
GlucoseBand.of(_:low:high:mmol:)inShared/classifies a reading at the precision shown to the user. A reading on a line is in range. The chart, BG text, chart scrubbing, contact image, stats pie, Live Activity widget, and the watch app and complications all use it (throughUnitSettingsStore.glucoseBand(for:thresholds:)in the app), replacing the repeated compare-and-pick-a-color blocks.GlucoseConversion.toDisplayPrecision): one decimal in mmol/L, whole numbers in mg/dL. Readings that display the same value always get the same band, and a line picked in mmol/L (3.9 is stored as 70.26) behaves in mg/dL like the 70 it displays.refreshFromCurrentState, the same path as a range-mode change, so the dismissed/enabled checks apply and a burst of picker changes collapses into one update (it lands after the existing 20 s refresh delay). Thresholds are published throughwriteThresholds()so the effective range is always used.effectiveThresholds(), so TIR and TITR modes match the chart, BG text and Live Activity.Alarms
The alarm-threshold change and the
BGPickerconversion factor were in this PR as a separate commit. As suggested in review, they are now their own PR, #839, which builds on this one. This PR is limited to colors and stats.