fix(forms): close the sheet as soon as a save lands

Saving a weight, a mood, a workout, a measurement edit or a quick-add
dose emptied the form and kept the button spinning until every read the
write touches had refetched (snapshot, digest, charts, insights). On a
slow connection that looked like nothing had been saved. The vaccination,
visit, address-book, symptom and check-up hooks did the same through an
onSuccess that returned the refetch, which a mutation waits for.

The forms now report and close first and start the refresh without
waiting for it; the hooks no longer return it. The quick-add loses a
second sweep of the inline compliance charts that the medication bundle
already covers, and its source pin follows.
This commit is contained in:
Marc-André Bombeck committed 2026-11-11 19:46:17 +01:00
1 parent 971d5d32cc
commit 4721914cac
13 files changed
+56 -33

No files matched your search

+3 -2
View File
@@ -166,10 +166,11 @@ export function useEncounterMutations() {
*
* So the fan-out is the visit roots PLUS the reminder reads, through the same
* helper the Vorsorge surfaces use, rather than a second sweep that could
* drift from it.
* drift from it. Not returned: a mutation would wait for every refetch
* before it settles, and the sheet would stay open until then.
*/
const invalidate = () =>
Promise.all([
void Promise.all([
invalidateKeys(qc, encounterDependentKeys),
invalidateReminderReads(qc),
]);
+2 -1
View File
@@ -117,7 +117,8 @@ export function useMeasurementReminders(enabled = true) {
export function useMeasurementReminderMutations() {
const qc = useQueryClient();
const invalidate = () => invalidateReminderReads(qc);
// Not returned: a mutation would wait for every refetch before it settles.
const invalidate = () => void invalidateReminderReads(qc);
const create = useMutation({
mutationKey: queryKeys.measurementReminderCreate(),
+3 -2
View File
@@ -62,9 +62,10 @@ export function usePractitionerMutations() {
const qc = useQueryClient();
// Renaming a practice changes the label a rail appointment renders under,
// and the daily reads are unmounted from the address book — pair the
// bundle invalidation with the forced inactive refetch.
// bundle invalidation with the forced inactive refetch. Not returned, so the
// sheet closes without waiting for the refetches.
const invalidate = () =>
Promise.all([
void Promise.all([
invalidateKeys(qc, encounterDependentKeys),
refetchInactiveDailyReads(qc),
]);