mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-07-25 17:10:21 -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>();
|
||||
|
||||
function addSubRecipeToMap(ing: RecipeIngredient, parentQuantity: number, parentScale: number, parentRecipe: Recipe) {
|
||||
const ref = ing.referencedRecipe!;
|
||||
const key = ref.id || ref.slug || "";
|
||||
const subRecipe = ing.referencedRecipe!;
|
||||
const key = subRecipe.id || subRecipe.slug || "";
|
||||
const ownIngs: ShoppingListIngredient[] = [];
|
||||
const subRefIngs: RecipeIngredient[] = [];
|
||||
|
||||
for (const subIng of ref.recipeIngredient ?? []) {
|
||||
for (const subIng of subRecipe.recipeIngredient ?? []) {
|
||||
if (subIng.referencedRecipe) {
|
||||
subRefIngs.push(subIng);
|
||||
}
|
||||
@@ -327,14 +327,14 @@ async function consolidateRecipesIntoSections(recipes: RecipeWithScale[]) {
|
||||
}
|
||||
|
||||
recipeSectionMap.set(key, {
|
||||
recipeId: ref.id || "",
|
||||
recipeName: ref.name || "",
|
||||
recipeId: subRecipe.id || "",
|
||||
recipeName: subRecipe.name || "",
|
||||
recipeScale: parentQuantity * parentScale,
|
||||
ingredientSections: buildIngredientSections(ownIngs),
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user