diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index 16beca7..cd5f6f7 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -601,15 +601,22 @@ async function applyBatchTags() { for (const id of pubIds) { const recipe = recipeStore.recipes.find(r => r._id === id) if (!recipe) continue + let newTags = [...recipe.tags] let changed = false for (const t of tagsToAdd) { - if (!recipe.tags.includes(t)) { recipe.tags.push(t); changed = true } + if (!newTags.includes(t)) { newTags.push(t); changed = true } } for (const t of tagsToRemove) { - const idx = recipe.tags.indexOf(t) - if (idx >= 0) { recipe.tags.splice(idx, 1); changed = true } + const idx = newTags.indexOf(t) + if (idx >= 0) { newTags.splice(idx, 1); changed = true } + } + if (changed) { + await api(`/api/recipes/${recipe._id}`, { + method: 'PUT', + body: JSON.stringify({ tags: newTags }), + }) + recipe.tags = newTags } - if (changed) await recipeStore.saveRecipe(recipe) } for (const id of diaryIds) { const d = diaryStore.userDiary.find(r => r.id === id)