Skip no-op saves in the edit dialogs; clear a stale model-spec error
Build image / build-and-push (push) Successful in 26s
Build image / build-and-push (push) Successful in 26s
A Save that changed nothing still sent a PATCH, which bumped the row's version and landed an "Edited garden settings" step in History that undid nothing — the drift is gone since the last commit, but the write was still there. Both dialogs now close without a request when every field matches the loaded row. In Settings, a rejected model spec's reason stayed under the field after the field was blanked back to the saved value; committing an unchanged value now clears it. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -98,6 +98,13 @@ export function GardenDialog({ garden, onClose }: { garden?: Garden; onClose: ()
|
||||
return
|
||||
}
|
||||
const input = { name: name.trim(), widthCm, heightCm, unitPref: unit, notes: notes.trim(), gridSizeCm, snapToGrid }
|
||||
// Nothing changed: close without a request. A PATCH that writes the same
|
||||
// row still bumps the version and lands an "Edited garden settings" step
|
||||
// in History that undoes nothing.
|
||||
if (isEdit && (Object.keys(input) as (keyof typeof input)[]).every((k) => input[k] === garden[k])) {
|
||||
onClose()
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (isEdit) await update.mutateAsync({ id: garden.id, ...input, version })
|
||||
else await create.mutateAsync(input)
|
||||
|
||||
Reference in New Issue
Block a user