Fix data loss when saving recipe with duplicate name

When a recipe save fails due to duplicate name, restore the original recipe data to prevent confusion and potential data loss when user navigates away.

Co-authored-by: hay-kot <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-29 14:10:45 +00:00
parent bd23896e34
commit 9247204f59

View File

@@ -352,6 +352,10 @@ async function saveRecipe() {
const { data, error } = await api.recipes.updateOne(recipe.value.slug, recipe.value); const { data, error } = await api.recipes.updateOne(recipe.value.slug, recipe.value);
if (!error) { if (!error) {
setMode(PageMode.VIEW); setMode(PageMode.VIEW);
} else {
// Restore original recipe data on error to prevent data loss
restoreOriginalRecipe();
return;
} }
if (data?.slug) { if (data?.slug) {
router.push(`/g/${groupSlug.value}/r/` + data.slug); router.push(`/g/${groupSlug.value}/r/` + data.slug);