Address cleanup review: no double error report; guard Leave onConfirm
Build image / build-and-push (push) Successful in 10s

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) <[email protected]>
Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ
This commit is contained in:
2026-07-22 10:04:49 -04:00
co-authored by Claude Opus 4.8
parent 9a8382c4a2
commit 440e43eb78
2 changed files with 8 additions and 2 deletions
@@ -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}
>
+3 -1
View File
@@ -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.
})
}