fix(medications): stop the delete confirm hanging in a spinner

Deleting a medication from the danger zone awaited a prefix-invalidate of
the "medications" key bundle before navigating. That bundle covers the
detail page's own active query, so the invalidation refetched the just-
deleted resource, hit a 404, retried with backoff, and never resolved —
the confirm button spun forever even though the delete had persisted.

Evict the detail query before invalidating, navigate to the list first,
then fire-and-forget the dependent-bundle invalidation. The busy state is
also cleared on the failed-response path. The detail query opts out of
retries so a deleted-resource refetch never burns a backoff cycle.
This commit is contained in:
Marc-André Bombeck committed 2026-06-01 19:36:33 +02:00
1 parent b3f61d0c75
commit ddb08b048a
2 files changed
+29 -6

No files matched your search

+5
View File
@@ -132,6 +132,11 @@ export default function MedicationDetailPage({
return (await res.json()).data as MedicationDetailSnapshot;
},
enabled: isAuthenticated,
// A deleted medication 404s here. Don't burn a retry/backoff cycle on
// a resource that no longer exists — the delete handler evicts this
// key on success, but `retry: false` hardens any caller that
// prefix-invalidates `["medications"]` while this page is mounted.
retry: false,
});
// v1.7.2 W3 — derive the wizard payload purely to feed the read-only