fix: Replace shadowed ref var name when adding recipe to shopping list (#7937)

This commit is contained in:
Michael Genson
2026-07-23 07:58:31 -05:00
committed by GitHub
parent afc277e1e3
commit 2c41923d47

View File

@@ -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) {