From 9d998b8aaa235a4e796f07223ad196b3f5e1303e Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:58:12 +0000 Subject: [PATCH] update function signatures to ignore isFood/disableAmount --- .../Domain/Recipe/RecipeIngredientListItem.vue | 2 +- .../RecipePageParts/RecipePageInstructions.vue | 7 +++---- .../components/Domain/Recipe/RecipePrintView.vue | 2 +- .../Domain/ShoppingList/ShoppingListItem.vue | 6 +----- .../use-extract-ingredient-references.ts | 8 ++++---- .../composables/recipes/use-recipe-ingredients.ts | 15 +++------------ 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/frontend/components/Domain/Recipe/RecipeIngredientListItem.vue b/frontend/components/Domain/Recipe/RecipeIngredientListItem.vue index 0c89f50c1..28d89d9e5 100644 --- a/frontend/components/Domain/Recipe/RecipeIngredientListItem.vue +++ b/frontend/components/Domain/Recipe/RecipeIngredientListItem.vue @@ -49,7 +49,7 @@ export default defineNuxtComponent({ }, setup(props) { const parsedIng = computed(() => { - return useParsedIngredientText(props.ingredient, props.disableAmount, props.scale); + return useParsedIngredientText(props.ingredient, props.scale); }); return { diff --git a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue index 65211b859..56c6812df 100644 --- a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue +++ b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue @@ -37,7 +37,7 @@ class="mb-n2 mt-n2" > @@ -53,7 +53,7 @@ class="mb-n2 mt-n2" > @@ -554,7 +554,6 @@ function autoSetReferences() { props.recipe.recipeIngredient, activeRefs.value, activeText.value, - props.recipe.settings.disableAmount, ).forEach((ingredient: string) => activeRefs.value.push(ingredient)); } @@ -576,7 +575,7 @@ function getIngredientByRefId(refId: string | undefined) { const ing = ingredientLookup.value[refId]; if (!ing) return ""; - return parseIngredientText(ing, props.recipe.settings.disableAmount, props.scale); + return parseIngredientText(ing, props.scale); } // =============================================================== diff --git a/frontend/components/Domain/Recipe/RecipePrintView.vue b/frontend/components/Domain/Recipe/RecipePrintView.vue index c9e0ee9ac..fff58054f 100644 --- a/frontend/components/Domain/Recipe/RecipePrintView.vue +++ b/frontend/components/Domain/Recipe/RecipePrintView.vue @@ -331,7 +331,7 @@ export default defineNuxtComponent({ }); function parseText(ingredient: RecipeIngredient) { - return parseIngredientText(ingredient, props.recipe.settings?.disableAmount || false, props.scale); + return parseIngredientText(ingredient, props.scale); } return { diff --git a/frontend/components/Domain/ShoppingList/ShoppingListItem.vue b/frontend/components/Domain/ShoppingList/ShoppingListItem.vue index 2d2bca96d..2d3404a5c 100644 --- a/frontend/components/Domain/ShoppingList/ShoppingListItem.vue +++ b/frontend/components/Domain/ShoppingList/ShoppingListItem.vue @@ -19,10 +19,7 @@ > @@ -170,7 +167,6 @@ @save="save" @cancel="toggleEdit(false)" @delete="$emit('delete')" - @toggle-foods="localListItem.isFood = !localListItem.isFood" /> diff --git a/frontend/composables/recipe-page/use-extract-ingredient-references.ts b/frontend/composables/recipe-page/use-extract-ingredient-references.ts index 4504bf612..3fa16a674 100644 --- a/frontend/composables/recipe-page/use-extract-ingredient-references.ts +++ b/frontend/composables/recipe-page/use-extract-ingredient-references.ts @@ -18,8 +18,8 @@ function removeStartingPunctuation(word: string): string { return word.replace(punctuationAtBeginning, ""); } -function ingredientMatchesWord(ingredient: RecipeIngredient, word: string, recipeIngredientAmountsDisabled: boolean) { - const searchText = parseIngredientText(ingredient, recipeIngredientAmountsDisabled); +function ingredientMatchesWord(ingredient: RecipeIngredient, word: string) { + const searchText = parseIngredientText(ingredient); return searchText.toLowerCase().includes(word.toLowerCase()); } @@ -39,7 +39,7 @@ function isBlackListedWord(word: string) { return blackListedText.includes(word) || word.match(blackListedRegexMatch); } -export function useExtractIngredientReferences(recipeIngredients: RecipeIngredient[], activeRefs: string[], text: string, recipeIngredientAmountsDisabled: boolean): Set { +export function useExtractIngredientReferences(recipeIngredients: RecipeIngredient[], activeRefs: string[], text: string): Set { const availableIngredients = recipeIngredients .filter(ingredient => ingredient.referenceId !== undefined) .filter(ingredient => !activeRefs.includes(ingredient.referenceId as string)); @@ -50,7 +50,7 @@ export function useExtractIngredientReferences(recipeIngredients: RecipeIngredie .map(normalize) .filter(word => word.length > 2) .filter(word => !isBlackListedWord(word)) - .flatMap(word => availableIngredients.filter(ingredient => ingredientMatchesWord(ingredient, word, recipeIngredientAmountsDisabled))) + .flatMap(word => availableIngredients.filter(ingredient => ingredientMatchesWord(ingredient, word))) .map(ingredient => ingredient.referenceId as string); // deduplicate diff --git a/frontend/composables/recipes/use-recipe-ingredients.ts b/frontend/composables/recipes/use-recipe-ingredients.ts index 362cda3d5..867fed639 100644 --- a/frontend/composables/recipes/use-recipe-ingredients.ts +++ b/frontend/composables/recipes/use-recipe-ingredients.ts @@ -36,16 +36,7 @@ function useUnitName(unit: CreateIngredientUnit | IngredientUnit | undefined, us return returnVal; } -export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmount: boolean, scale = 1, includeFormating = true) { - if (disableAmount) { - return { - name: ingredient.note ? sanitizeIngredientHTML(ingredient.note) : undefined, - quantity: undefined, - unit: undefined, - note: undefined, - }; - } - +export function useParsedIngredientText(ingredient: RecipeIngredient, scale = 1, includeFormating = true) { const { quantity, food, unit, note } = ingredient; const usePluralUnit = quantity !== undefined && ((quantity || 0) * scale > 1 || (quantity || 0) * scale === 0); const usePluralFood = (!quantity) || quantity * scale > 1; @@ -82,8 +73,8 @@ export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmo }; } -export function parseIngredientText(ingredient: RecipeIngredient, disableAmount: boolean, scale = 1, includeFormating = true): string { - const { quantity, unit, name, note } = useParsedIngredientText(ingredient, disableAmount, scale, includeFormating); +export function parseIngredientText(ingredient: RecipeIngredient, scale = 1, includeFormating = true): string { + const { quantity, unit, name, note } = useParsedIngredientText(ingredient, scale, includeFormating); const text = `${quantity || ""} ${unit || ""} ${name || ""} ${note || ""}`.replace(/ {2,}/g, " ").trim(); return sanitizeIngredientHTML(text);