Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Fix fav recipes (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Cuadra committed Sep 21, 2018
1 parent ad1bb88 commit beab581
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Layout extends Component {
try {
const { menu } = calculateDayMenu({
recipes: prioritizeAndSort(state.recipes, state.recipesFavoriteKeys),
recipesFavoriteKeys: state.recipesFavoriteKeys,
settings,
});

Expand Down
7 changes: 6 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ export function calculateDayMenu({
protein = 0,
recipeIndex = 0,
recipes = List([]),
recipesFavoriteKeys,
consumedServings = 0,
settings = {},
}) {
const shouldExit = recipeIndex >= recipes.size;

if (shouldExit) {
const isCaloriesOutOfBounds =
calories < settings.CALORIES_LOWER_BOUND ||
Expand All @@ -74,7 +76,8 @@ export function calculateDayMenu({

if (shouldRestart) {
return calculateDayMenu({
recipes: recipes.sort(randomSort),
recipes: prioritizeAndSort(recipes, recipesFavoriteKeys),
recipesFavoriteKeys,
settings,
});
}
Expand Down Expand Up @@ -105,6 +108,7 @@ export function calculateDayMenu({
protein,
recipeIndex: recipeIndex + 1,
recipes,
recipesFavoriteKeys,
consumedServings: 0,
settings,
});
Expand All @@ -118,6 +122,7 @@ export function calculateDayMenu({
protein: proteinCounted,
recipeIndex,
recipes,
recipesFavoriteKeys,
consumedServings: consumedServings + 1,
settings,
});
Expand Down

0 comments on commit beab581

Please sign in to comment.