fix(dashboard): a dose taken on the dashboard updates the dashboard

The hero band, dose tally, verdict and checklist all read one snapshot
query that neither refetches on mount nor on focus — and no mutation
ever invalidated its key, so a dose taken right there stayed visibly
due for up to the next two-minute poll. The snapshot key joins the
medication-dependent invalidation bundle; the intake routes already
hard-evict the server-side bucket, so the triggered refetch returns
post-write data immediately. (#316)
This commit is contained in:
Marc-André Bombeck committed 2026-06-12 21:47:47 +02:00
1 parent 45e391c60a
commit 19a24a5160
2 files changed
+18

No files matched your search

+9
View File
@@ -250,6 +250,15 @@ describe("dependent-key bundles", () => {
const keyStrings = medicationDependentKeys.map((k) => JSON.stringify(k));
expect(keyStrings).toContain(JSON.stringify(["compliance-chart-inline"]));
});
// v1.16.11 — the dashboard snapshot feeds the hero band, dose tally,
// verdict and checklist from ONE query with refetch-on-mount/focus
// off and a 120 s poll. Without this key in the bundle a dose taken
// from the dashboard stayed visibly due until the next poll (#316).
it("medicationDependentKeys bundles the dashboard snapshot (v1.16.11)", () => {
const keyStrings = medicationDependentKeys.map((k) => JSON.stringify(k));
expect(keyStrings).toContain(JSON.stringify(["dashboard", "snapshot"]));
});
});
/**
+9
View File
@@ -103,6 +103,14 @@ export const moodDependentKeys = [
* `queryKeys.medicationDetail(id)` rides under the
* `["medications"]` prefix already so a single medication invalidation
* also evicts its detail-page read.
*
* v1.16.11 — `dashboardSnapshot` joins the bundle. The hero band, dose
* tally, verdict and checklist all read ONE snapshot query configured
* with refetchOnMount/WindowFocus off and a 120 s poll; without the key
* here a dose taken from the dashboard stayed visibly due for up to two
* minutes. The intake routes already hard-evict the server-side
* snapshot bucket, so the refetch this triggers returns post-write data
* immediately.
*/
export const medicationDependentKeys = [
queryKeys.medications(),
@@ -110,6 +118,7 @@ export const medicationDependentKeys = [
queryKeys.insightsRoot(),
queryKeys.insightsTargets(),
queryKeys.gamificationAchievements(),
queryKeys.dashboardSnapshot(),
["dashboard-medication-compliance"] as const,
["compliance-chart-inline"] as const,
];