fix(medications): the cards hold one shape and the list refetches on return

The low-supply notice moves onto the adherence meta row beside the streak —
a slot every card already reserves in every state — so a card that is low
on stock no longer inserts a row that pushes its bars out of line with the
card beside it. The gap between the drug class and the first line tightens
at the same time.

The medications list, compliance summary and supply reads now refetch on
every mount. App Router unmounts the page on navigation away and remounts
it on return; inside the client staleTime that return served a cache that
could be minutes old, hiding a dose logged on another device or surface. A
Playwright spec guards the return-navigation refetch.
This commit is contained in:
Marc-André Bombeck committed 2026-06-13 16:08:01 +02:00
1 parent f4dec8c28f
commit ff92ba46c2
5 files changed
+197 -59

No files matched your search

@@ -64,11 +64,14 @@ export function useMedicationComplianceSummary(medicationId: string): {
const { data, isError, refetch } = useQuery({
queryKey: queryKeys.medicationComplianceSummary(),
queryFn: fetchComplianceSummary,
// Dose actions invalidate the key explicitly through
// `medicationDependentKeys`; a shorter window would only re-fire the
// batch on every list visit. Matches the reminder-thresholds query
// the cards mount alongside.
// Dose actions in this tab invalidate the key through
// `medicationDependentKeys`. v1.16.12 (#316) — but a dose logged on
// another surface (the iOS app) leaves this stale for up to the
// window, so refetch on every mount: returning to the page reflects
// cross-device intakes without a manual reload. The batched read is
// one request per visit, server-cached.
staleTime: 5 * 60 * 1000,
refetchOnMount: "always",
select: (rows: MedicationComplianceSummaryEntry[]) =>
rows.find((row) => row.medicationId === medicationId) ?? null,
});
@@ -88,6 +91,8 @@ export function useMedicationComplianceSummaryAll(): {
queryKey: queryKeys.medicationComplianceSummary(),
queryFn: fetchComplianceSummary,
staleTime: 5 * 60 * 1000,
// v1.16.12 (#316) — fresh on return-navigation (see the per-row hook).
refetchOnMount: "always",
});
return { data };
}