mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-20 06:43:11 -05:00
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:
@@ -352,6 +352,10 @@ async function saveRecipe() {
|
||||
const { data, error } = await api.recipes.updateOne(recipe.value.slug, recipe.value);
|
||||
if (!error) {
|
||||
setMode(PageMode.VIEW);
|
||||
} else {
|
||||
// Restore original recipe data on error to prevent data loss
|
||||
restoreOriginalRecipe();
|
||||
return;
|
||||
}
|
||||
if (data?.slug) {
|
||||
router.push(`/g/${groupSlug.value}/r/` + data.slug);
|
||||
|
||||
Reference in New Issue
Block a user