mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
fix: Ingredient sections lost after parsing (#1368)
* fixed bug where ingredient titles were lost after parsing * added fallback in case of strange behavior during parsing * removed unnecessary linebreak
This commit is contained in:
parent
92ccbae657
commit
504bf41b9c
@ -140,6 +140,16 @@ export default defineComponent({
|
|||||||
const { data } = await api.recipes.parseIngredients(parser.value, raw);
|
const { data } = await api.recipes.parseIngredients(parser.value, raw);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
// When we send the recipe ingredient text to be parsed, we lose the reference to the original unparsed ingredient.
|
||||||
|
// Generally this is fine, but if the unparsed ingredient had a title, we lose it; we add back the title for each ingredient here.
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < recipe.value.recipeIngredient.length; i++) {
|
||||||
|
data[i].ingredient.title = recipe.value.recipeIngredient[i].title;
|
||||||
|
}
|
||||||
|
} catch (TypeError) {
|
||||||
|
console.error("Index Mismatch Error during recipe ingredient parsing; did the number of ingredients change?")
|
||||||
|
}
|
||||||
|
|
||||||
parsedIng.value = data;
|
parsedIng.value = data;
|
||||||
|
|
||||||
errors.value = data.map((ing, index: number) => {
|
errors.value = data.map((ing, index: number) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user