From 794504dee0d29e450245dceb929e63e89cdc6e7b Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sat, 1 Oct 2022 15:36:30 +1300 Subject: [PATCH] Use latest image for new sets Previously, it would use the image from the best ranked set. --- SetList.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SetList.tsx b/SetList.tsx index 67747ac..bde767a 100644 --- a/SetList.tsx +++ b/SetList.tsx @@ -45,9 +45,10 @@ export default function SetList() { setWorkouts(todaysWorkouts); let workout = todaysWorkouts[0]; let best = await getBestSet(workout); + let [{image}] = await getSets({search: best.name, limit: 1, offset: 0}); console.log(`${SetList.name}.predict:`, {workout, best}); if (!todaysSet || !todaysWorkouts.includes(todaysSet.name)) - return setSet(best); + return setSet({...best, image}); let _count = await countToday(todaysSet.name); console.log(`${SetList.name}.predict:`, {_count}); workout = todaysSet.name; @@ -55,11 +56,12 @@ export default function SetList() { const index = todaysWorkouts.indexOf(todaysSet.name) + 1; if (_count >= Number(best.sets)) { best = await getBestSet(todaysWorkouts[index]); + [{image}] = await getSets({search: best.name, limit: 1, offset: 0}); _count = 0; } if (best.name === '') setCount(0); else setCount(_count); - setSet(best); + setSet({...best, image}); }, []); const refresh = useCallback(async () => {