From f2f1e5f036c1b5b5dc49dfb88e2d64bddd6cd80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 17 May 2026 17:24:08 +0200 Subject: [PATCH] fix(dashboard): share medications cache between checklist and quick-add MedicationIntakeQuickAdd's useQuery shared the queryKey with the onboarding-checklist subscriber but ran with default staleTime=0, so every sheet open triggered a fresh `/api/medications` GET even when the parent dashboard cache already held current data. Match the dashboard's 60s staleTime and disable refetch-on-mount / refetch-on-window-focus so opening the sheet inside the TTL reads straight from the React-Query cache. --- .../dashboard/medication-intake-quick-add.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/dashboard/medication-intake-quick-add.tsx b/src/components/dashboard/medication-intake-quick-add.tsx index db3fd4c2c..73ba8c451 100644 --- a/src/components/dashboard/medication-intake-quick-add.tsx +++ b/src/components/dashboard/medication-intake-quick-add.tsx @@ -165,6 +165,17 @@ export function MedicationIntakeQuickAdd({ const json = await res.json(); return json.data as MedicationOption[]; }, + // v1.4.38 — share the parent dashboard's medications cache. + // `queryKeys.medications()` resolves to `["medications"]` — the + // same key the dashboard's onboarding checklist subscriber holds. + // Without a staleTime the sheet-mount triggers a fresh + // `/api/medications` GET on every open even when the parent cache + // already has current data. Match the dashboard's 60s window and + // skip the refetch-on-mount so opening the sheet inside the TTL + // reads straight from the React-Query cache. + staleTime: 60_000, + refetchOnMount: false, + refetchOnWindowFocus: false, }); const medications = useMemo(