mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
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.
This commit is contained in:
1 parent
01cc1f78cd
commit
f2f1e5f036
1 file changed
+11
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user