diff --git a/src/lib/__tests__/query-keys.test.ts b/src/lib/__tests__/query-keys.test.ts index 1e56d87d3..5b1e70f5f 100644 --- a/src/lib/__tests__/query-keys.test.ts +++ b/src/lib/__tests__/query-keys.test.ts @@ -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"])); + }); }); /** diff --git a/src/lib/query-keys/index.ts b/src/lib/query-keys/index.ts index c91b1a386..e98e8d0a5 100644 --- a/src/lib/query-keys/index.ts +++ b/src/lib/query-keys/index.ts @@ -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, ];