mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
Pair every daily-read invalidation with its inactive refetch
Ten client mutation sites forgot a consumer: a coach-accepted checkup stayed invisible for up to five minutes, a threshold or target edit left the dashboard bands stale, a score-config save marked the daily reads stale but never refetched them, a booked visit missed the Today rail, a source-priority reorder kept every chart on the old canonical picks, an adopted self-context note never reached the Settings read. Each site now invalidates what its write changed and forces the unmounted snapshot + digest reads to refetch through refetchInactiveDailyReads. New illnessDependentKeys bundle carries the daily reads (Rest Mode frames both), dailyDigest joins encounterDependentKeys, and the chart-data prefix gains a factory accessor for whole-cache flushes. The daily-reads guard learns the cycle / encounter / vaccination / illness bundle families and a second matcher for direct snapshot/digest invalidateQueries without a forced refetch, each with a frozen reasoned allowlist. Both matchers were proven live by reverting a fix and watching the guard go red (see the test doc comment).
This commit is contained in:
1 parent
002d120b69
commit
f2f40ae8b2
17 files changed
+239
-24
No files matched your search
@@ -240,6 +240,22 @@ export const medicationDependentKeys = [
|
||||
*/
|
||||
export const cycleDependentKeys = [queryKeys.cycle(), queryKeys.insightsRoot()];
|
||||
|
||||
/**
|
||||
* Keys invalidated when an illness episode starts, ends, is edited, deleted,
|
||||
* restored, or a day-log lands. Rest Mode derives from the active-episode set
|
||||
* and both daily reads annotate from it (the hero band's "unwell since" frame,
|
||||
* the digest's paused nudges), so an episode write must reach the snapshot and
|
||||
* digest keys, not only the `["illness"]` tree. Pair every call site with
|
||||
* `refetchInactiveDailyReads` — the daily reads are typically unmounted while
|
||||
* the user is on the illness surface, and a bare invalidation would mark them
|
||||
* stale without refetching (the recurring v1.16.11/v1.29.1/v1.32.19 class).
|
||||
*/
|
||||
export const illnessDependentKeys = [
|
||||
queryKeys.illness(),
|
||||
queryKeys.dashboardSnapshot(),
|
||||
queryKeys.dailyDigest(),
|
||||
];
|
||||
|
||||
/**
|
||||
* Keys invalidated when a visit or an address-book entry changes.
|
||||
*
|
||||
@@ -257,6 +273,12 @@ export const cycleDependentKeys = [queryKeys.cycle(), queryKeys.insightsRoot()];
|
||||
export const encounterDependentKeys = [
|
||||
queryKeys.encounters(),
|
||||
queryKeys.practitioners(),
|
||||
// A booked / rescheduled / removed appointment is a row the Today digest
|
||||
// surfaces, so it must appear on the rail in the same tick as the visit
|
||||
// list. Pair call sites with `refetchInactiveDailyReads` (or the
|
||||
// `invalidateReminderReads` helper, which carries it) — the digest is
|
||||
// typically unmounted while the user is on the visits surface.
|
||||
queryKeys.dailyDigest(),
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,6 +72,14 @@ export const measurementKeys = {
|
||||
* fetch window; the factory packs those into a single tuple to keep
|
||||
* the cache layout byte-identical with the pre-v1.4.40 layout.
|
||||
*/
|
||||
/**
|
||||
* Prefix key — invalidates every `chartData(…)` / `chartSeriesBatch(…)`
|
||||
* slot at once via TanStack's hierarchical-prefix semantics. For call
|
||||
* sites outside the factory that need the whole per-chart cache flushed
|
||||
* (a source-priority reorder changes every chart's canonical-row picks).
|
||||
*/
|
||||
chartDataRoot: () => ["chart-data"] as const,
|
||||
|
||||
chartData: (
|
||||
types: string,
|
||||
valueMode: string,
|
||||
|
||||
Reference in new issue
Block a user