Fix infinite loop in meal planner randomizer (#346)

Infinite loop would happen if there were more days than recipes
This commit is contained in:
sephrat 2021-04-24 00:31:21 +02:00 committed by GitHub
parent b729c0e15a
commit 21d2fb4b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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];