diff --git a/src/__tests__/success-affordance-guard.test.ts b/src/__tests__/success-affordance-guard.test.ts index ab20989db..8cd324ece 100644 --- a/src/__tests__/success-affordance-guard.test.ts +++ b/src/__tests__/success-affordance-guard.test.ts @@ -248,6 +248,9 @@ const PINNED_AFFORDANCES: Record< "src/components/medications/sections/inventory-dialogs.tsx": { "toast.success": 3, }, + "src/components/medications/sections/intake-tracking-section.tsx": { + "toast.success": 1, + }, "src/components/medications/sections/inventory-section.tsx": { "toast.success": 1, }, diff --git a/src/components/medications/sections/intake-tracking-section.tsx b/src/components/medications/sections/intake-tracking-section.tsx index 4607c7e92..21b86e397 100644 --- a/src/components/medications/sections/intake-tracking-section.tsx +++ b/src/components/medications/sections/intake-tracking-section.tsx @@ -16,7 +16,11 @@ import { toast } from "sonner"; import { Switch } from "@/components/ui/switch"; import { useTranslations } from "@/lib/i18n/context"; -import { invalidateKeys, medicationDependentKeys } from "@/lib/query-keys"; +import { + invalidateKeys, + medicationDependentKeys, + refetchInactiveDailyReads, +} from "@/lib/query-keys"; import { apiPut } from "@/lib/api/api-fetch"; const SWITCH_ID = "medication-detail-track-intake-switch"; @@ -43,6 +47,9 @@ export function IntakeTrackingBody({ try { await apiPut(`/api/medications/${medicationId}`, { trackIntake: next }); await invalidateKeys(queryClient, medicationDependentKeys); + // The doses card and the Today digest read this medication's due + // state; they are usually unmounted here, so refetch them now. + await refetchInactiveDailyReads(queryClient); toast.success( next ? t("medications.trackIntake.enabledToast")