From 440e43eb785ad7655925744a141e629bde4b925c Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Wed, 22 Jul 2026 10:04:49 -0400 Subject: [PATCH] Address cleanup review: no double error report; guard Leave onConfirm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gadfly on #107: - ClearBed reported a failure twice — ConfirmModal's inline Alert AND useClearObject's own onError toast. Dropped the toast from useClearObject (its only caller is that modal now), so the failure shows once, inline in the dialog where the action is. - LeaveGarden's onConfirm silently resolved (closing the dialog as if it worked) if me.data was missing, relying on confirmDisabled to prevent it. Throw instead, so a drift in that guard surfaces an error rather than a fake success. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ --- web/src/components/gardens/LeaveGardenModal.tsx | 6 +++++- web/src/lib/objects.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/components/gardens/LeaveGardenModal.tsx b/web/src/components/gardens/LeaveGardenModal.tsx index 2b82e26..5ccb540 100644 --- a/web/src/components/gardens/LeaveGardenModal.tsx +++ b/web/src/components/gardens/LeaveGardenModal.tsx @@ -16,7 +16,11 @@ export function LeaveGardenModal({ garden, onClose }: { garden: Garden; onClose: confirmDisabled={!me.data} errorFallback="Could not leave the garden." onConfirm={async () => { - if (me.data) await remove.mutateAsync(me.data.id) + // The button is disabled without a current user; throw rather than + // silently resolve (which would close the dialog as if it had worked) if + // that guard ever drifts. + if (!me.data) throw new Error('Not signed in.') + await remove.mutateAsync(me.data.id) }} onClose={onClose} > diff --git a/web/src/lib/objects.ts b/web/src/lib/objects.ts index 9c0a4e0..4694dfc 100644 --- a/web/src/lib/objects.ts +++ b/web/src/lib/objects.ts @@ -381,7 +381,9 @@ export function useClearObject(gardenId: number) { return res.cleared }, onSettled: () => qc.invalidateQueries({ queryKey: fullKey(gardenId) }), - onError: (err) => toast.error(objectErrorMessage(err, 'Could not clear the bed.')), + // No toast: the only caller (ClearBedModal → ConfirmModal) shows the failure + // inline in the dialog, which is more contextual than a detached toast — and + // two of them for one failure is worse than one. }) }