Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(today/vitals): apply Settings visibility + chart-detail changes immediately - #70

Merged
saksham2001 merged 2 commits into
saksham2001:mainfrom
rgvxsthi:fix/settings-visibility-reactivity
Jul 12, 2026
Merged

saksham2001 merged 2 commits into
saksham2001:mainfrom
rgvxsthi:fix/settings-visibility-reactivity

Conversation

@rgvxsthi

@rgvxsthi rgvxsthi commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Bug

Today/Vitals didn't reflect a change made in Settings → Visible tiles / Chart detail (VitalsSettingsView) until an unrelated event later forced a rebuild.

TodayStore/VitalsStore rebuild only when a cheap currentSignature() changes (refreshIfNeeded() guards sig != signature). But the signature was built from measurements, activity, sleep, device, calibration, and profile.updatedAt — it omitted the per-scope visibility (hiddenMetrics/todayHiddenMetrics) and chart-detail (resolution/todayResolution) prefs. And MetricPrefsStore.setHidden/setResolution only persist to UserDefaults (no PulseDataChange bump).

Failure

Settings → toggle a tile off → return to Today/Vitals → the tab-activation path calls refreshIfNeeded(), but the recomputed signature is identical (prefs aren't in it) → guard returns → no rebuild. The tile stays until an unrelated ring sync / profile edit changes the signature and the deferred rebuild finally reads the new prefs. (The read path itself is correct — computeVisible/metricRange do read the prefs; the defect is that a pref change never triggers a rebuild.)

Fix

Fold the scoped prefs into each store's signature:

  • TodayStoretodayHiddenMetrics (sorted) + todayResolution
  • VitalsStorehiddenMetrics (sorted) + resolution

Returning to the tab already calls refreshIfNeeded (isActive → updateProfile), so with the prefs in the signature that same return now detects the change and rebuilds. No new observation plumbing; scoped so a Today change doesn't rebuild Vitals. (Note: bumping PulseDataChange in the setters alone would NOT fix it — refreshIfNeeded is signature-gated, so the signature must change regardless.)

Medium severity — user-visible "my setting didn't apply" papercut on a shipping feature; no crash, data intact. Builds clean.

…mmediately

TodayStore/VitalsStore rebuild only when a cheap currentSignature() changes, but
the signature omitted the per-scope visibility (hiddenMetrics/todayHiddenMetrics)
and chart-detail (resolution/todayResolution) prefs. So toggling a tile off/on or
changing 'Chart detail' in Settings (VitalsSettingsView) persisted to UserDefaults
but never changed the signature — refreshIfNeeded() no-op'd on tab return, and the
grid/charts kept the old layout until an unrelated event (a ring sync or profile
edit) happened to bump the signature.

Fold the scoped prefs into each store's signature. Returning to the tab already
calls refreshIfNeeded (isActive -> updateProfile), so with the prefs in the
signature that return now detects the change and rebuilds. Scoped per store so a
Today change doesn't needlessly rebuild Vitals.
@rgvxsthi
rgvxsthi requested a review from saksham2001 as a code owner July 9, 2026 12:10
@saksham2001
saksham2001 merged commit ac2b81a into saksham2001:main Jul 12, 2026
2 checks passed
@rgvxsthi
rgvxsthi deleted the fix/settings-visibility-reactivity branch July 12, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants