From 21d2fb4b93cb6e3bd18d560f79c9b6dac669870b Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Sat, 24 Apr 2021 00:31:21 +0200 Subject: [PATCH] Fix infinite loop in meal planner randomizer (#346) 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 e3938f318b60..082faded32d4 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];