Simplify set prediction by returning early
This commit is contained in:
parent
cdb4ceec28
commit
64d046fe8f
28
SetList.tsx
28
SetList.tsx
|
@ -36,26 +36,24 @@ export default function SetList() {
|
||||||
if (!settings.predict) return;
|
if (!settings.predict) return;
|
||||||
const todaysPlan = await getTodaysPlan();
|
const todaysPlan = await getTodaysPlan();
|
||||||
if (todaysPlan.length === 0) return;
|
if (todaysPlan.length === 0) return;
|
||||||
const todaysSet = await getToday();
|
|
||||||
const todaysWorkouts = todaysPlan[0].workouts.split(',');
|
const todaysWorkouts = todaysPlan[0].workouts.split(',');
|
||||||
setWorkouts(todaysWorkouts);
|
setWorkouts(todaysWorkouts);
|
||||||
let workout = todaysWorkouts[0];
|
let workout = todaysWorkouts[0];
|
||||||
let best = await getBestSet(workout);
|
let best = await getBestSet(workout);
|
||||||
console.log({todaysSet, todaysWorkouts, todaysPlan});
|
const todaysSet = await getToday();
|
||||||
if (todaysSet && todaysWorkouts.includes(todaysSet.name)) {
|
if (!todaysSet || !todaysWorkouts.includes(todaysSet.name))
|
||||||
let _count = await countToday(todaysSet.name);
|
return setSet(best);
|
||||||
workout = todaysSet.name;
|
let _count = await countToday(todaysSet.name);
|
||||||
best = await getBestSet(workout);
|
workout = todaysSet.name;
|
||||||
const index = todaysWorkouts.indexOf(todaysSet.name) + 1;
|
best = await getBestSet(workout);
|
||||||
if (_count >= Number(best.sets)) {
|
const index = todaysWorkouts.indexOf(todaysSet.name) + 1;
|
||||||
best = await getBestSet(todaysWorkouts[index]);
|
if (_count >= Number(best.sets)) {
|
||||||
_count = 0;
|
best = await getBestSet(todaysWorkouts[index]);
|
||||||
}
|
_count = 0;
|
||||||
if (best.name === '') setCount(0);
|
|
||||||
else setCount(_count);
|
|
||||||
}
|
}
|
||||||
console.log({best});
|
if (best.name === '') setCount(0);
|
||||||
setSet({...best});
|
else setCount(_count);
|
||||||
|
setSet(best);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const refresh = useCallback(async () => {
|
const refresh = useCallback(async () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user