From 2b3efed401b00936c5c0238d8e3fbdd3f439e6c3 Mon Sep 17 00:00:00 2001 From: Florian Dupret <34862846+sephrat@users.noreply.github.com> Date: Fri, 23 Apr 2021 15:41:29 +0200 Subject: [PATCH] Fix infinite loop in meal planner randomizer Infinite loop would happen if there were more days than recipes --- frontend/src/components/MealPlan/MealPlanNew.vue | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frontend/src/components/MealPlan/MealPlanNew.vue b/frontend/src/components/MealPlan/MealPlanNew.vue index e3938f318..082faded3 100644 --- a/frontend/src/components/MealPlan/MealPlanNew.vue +++ b/frontend/src/components/MealPlan/MealPlanNew.vue @@ -167,11 +167,7 @@ export default { } }, getRandom(list) { - let recipe = 1; - while (this.usedRecipes.includes(recipe)) { - recipe = list[Math.floor(Math.random() * list.length)]; - } - return recipe; + return list[Math.floor(Math.random() * list.length)]; }, random() { this.usedRecipes = [1];