mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-13 13:27:29 -04:00
fix: redirect to new slug URL after recipe rename (#7522)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -336,8 +336,16 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// When set, the isEditMode watcher skips its URL cleanup because saveRecipe
|
||||||
|
// is navigating to a new slug that naturally omits ?edit=true.
|
||||||
|
const isNavigatingAfterRename = ref(false);
|
||||||
|
|
||||||
watch(isEditMode, (newVal) => {
|
watch(isEditMode, (newVal) => {
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
|
if (isNavigatingAfterRename.value) {
|
||||||
|
isNavigatingAfterRename.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
paramsEdit.value = undefined;
|
paramsEdit.value = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -355,13 +363,17 @@ watch(isParsing, () => {
|
|||||||
async function saveRecipe() {
|
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) {
|
||||||
|
if (data?.slug && data.slug !== route.params.slug) {
|
||||||
|
isNavigatingAfterRename.value = true;
|
||||||
|
}
|
||||||
setMode(PageMode.VIEW);
|
setMode(PageMode.VIEW);
|
||||||
}
|
}
|
||||||
if (data?.slug) {
|
if (data?.slug) {
|
||||||
router.push(`/g/${groupSlug.value}/r/` + data.slug);
|
|
||||||
recipe.value = data as NoUndefinedField<Recipe>;
|
recipe.value = data as NoUndefinedField<Recipe>;
|
||||||
// Update the snapshot after successful save
|
|
||||||
originalRecipe.value = deepCopy(recipe.value);
|
originalRecipe.value = deepCopy(recipe.value);
|
||||||
|
if (data.slug !== route.params.slug) {
|
||||||
|
router.replace(`/g/${groupSlug.value}/r/` + data.slug);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user