Simplify set prediction by returning early

This commit is contained in:
Brandon Presley 2022-09-28 14:06:51 +13:00
parent cdb4ceec28
commit 64d046fe8f

View File

@ -36,13 +36,13 @@ export default function SetList() {
if (!settings.predict) return;
const todaysPlan = await getTodaysPlan();
if (todaysPlan.length === 0) return;
const todaysSet = await getToday();
const todaysWorkouts = todaysPlan[0].workouts.split(',');
setWorkouts(todaysWorkouts);
let workout = todaysWorkouts[0];
let best = await getBestSet(workout);
console.log({todaysSet, todaysWorkouts, todaysPlan});
if (todaysSet && todaysWorkouts.includes(todaysSet.name)) {
const todaysSet = await getToday();
if (!todaysSet || !todaysWorkouts.includes(todaysSet.name))
return setSet(best);
let _count = await countToday(todaysSet.name);
workout = todaysSet.name;
best = await getBestSet(workout);
@ -53,9 +53,7 @@ export default function SetList() {
}
if (best.name === '') setCount(0);
else setCount(_count);
}
console.log({best});
setSet({...best});
setSet(best);
}, []);
const refresh = useCallback(async () => {