mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-07-25 00:50:14 -04:00
fix: Replace shadowed ref var name when adding recipe to shopping list (#7937)
This commit is contained in:
@@ -308,12 +308,12 @@ async function consolidateRecipesIntoSections(recipes: RecipeWithScale[]) {
|
|||||||
const recipeSectionMap = new Map<string, ShoppingListRecipeIngredientSection>();
|
const recipeSectionMap = new Map<string, ShoppingListRecipeIngredientSection>();
|
||||||
|
|
||||||
function addSubRecipeToMap(ing: RecipeIngredient, parentQuantity: number, parentScale: number, parentRecipe: Recipe) {
|
function addSubRecipeToMap(ing: RecipeIngredient, parentQuantity: number, parentScale: number, parentRecipe: Recipe) {
|
||||||
const ref = ing.referencedRecipe!;
|
const subRecipe = ing.referencedRecipe!;
|
||||||
const key = ref.id || ref.slug || "";
|
const key = subRecipe.id || subRecipe.slug || "";
|
||||||
const ownIngs: ShoppingListIngredient[] = [];
|
const ownIngs: ShoppingListIngredient[] = [];
|
||||||
const subRefIngs: RecipeIngredient[] = [];
|
const subRefIngs: RecipeIngredient[] = [];
|
||||||
|
|
||||||
for (const subIng of ref.recipeIngredient ?? []) {
|
for (const subIng of subRecipe.recipeIngredient ?? []) {
|
||||||
if (subIng.referencedRecipe) {
|
if (subIng.referencedRecipe) {
|
||||||
subRefIngs.push(subIng);
|
subRefIngs.push(subIng);
|
||||||
}
|
}
|
||||||
@@ -327,14 +327,14 @@ async function consolidateRecipesIntoSections(recipes: RecipeWithScale[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipeSectionMap.set(key, {
|
recipeSectionMap.set(key, {
|
||||||
recipeId: ref.id || "",
|
recipeId: subRecipe.id || "",
|
||||||
recipeName: ref.name || "",
|
recipeName: subRecipe.name || "",
|
||||||
recipeScale: parentQuantity * parentScale,
|
recipeScale: parentQuantity * parentScale,
|
||||||
ingredientSections: buildIngredientSections(ownIngs),
|
ingredientSections: buildIngredientSections(ownIngs),
|
||||||
parentRecipe,
|
parentRecipe,
|
||||||
});
|
});
|
||||||
|
|
||||||
subRefIngs.forEach(subIng => addSubRecipeToMap(subIng, (ing.quantity || 1) * (subIng.quantity || 1), parentScale, ref));
|
subRefIngs.forEach(subIng => addSubRecipeToMap(subIng, (ing.quantity || 1) * (subIng.quantity || 1), parentScale, subRecipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const recipe of recipes) {
|
for (const recipe of recipes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user