Revert "Show count when adding a new set"

This reverts commit 4aa91253a1.
This commit is contained in:
Brandon Presley 2022-09-09 15:32:47 +12:00
parent 4aa91253a1
commit d5c97b45b0
3 changed files with 10 additions and 20 deletions

View File

@ -21,20 +21,14 @@ export default function EditSet() {
useFocusEffect(
useCallback(() => {
getSettings().then(settings => {
let title = 'Edit set';
if (!params.set.id && params.set.name)
title = `Add set (${params.count} / ${settings.sets})`;
if (!params.set.id && !params.set.name) title = 'Add set';
navigation.getParent()?.setOptions({
headerLeft: () => (
<IconButton icon="arrow-back" onPress={() => navigation.goBack()} />
),
headerRight: null,
title,
});
navigation.getParent()?.setOptions({
headerLeft: () => (
<IconButton icon="arrow-back" onPress={() => navigation.goBack()} />
),
headerRight: null,
title: params.set.id ? 'Edit set' : 'Create set',
});
}, [navigation, params]),
}, [navigation, params.set.id]),
);
const startTimer = useCallback(async () => {

View File

@ -13,7 +13,6 @@ export type HomePageParams = {
Sets: {};
EditSet: {
set: Set;
count: number;
workouts?: string[];
};
};

View File

@ -21,7 +21,6 @@ const limit = 15;
export default function SetList() {
const [sets, setSets] = useState<Set[]>();
const [set, setSet] = useState<Set>();
const [count, setCount] = useState(1);
const [workouts, setWorkouts] = useState<string[]>([]);
const [offset, setOffset] = useState(0);
const [search, setSearch] = useState('');
@ -53,12 +52,11 @@ export default function SetList() {
let workout = todaysWorkouts[0];
console.log(`${SetList.name}.predict:`, {todaysSets, todaysWorkouts});
if (todaysWorkouts.includes(todaysSets[0]?.name) && todaysSets.length > 0) {
const _count = todaysSets.filter(
const count = todaysSets.filter(
s => s.name === todaysSets[0].name,
).length;
setCount(_count);
workout = todaysSets[0].name;
if (_count >= Number(settings.sets))
if (count >= Number(settings.sets))
workout =
todaysWorkouts[todaysWorkouts.indexOf(todaysSets[0].name!) + 1];
}
@ -119,10 +117,9 @@ export default function SetList() {
const onAdd = useCallback(async () => {
navigation.navigate('EditSet', {
set: set || {...defaultSet},
count,
workouts,
});
}, [navigation, set, workouts, count]);
}, [navigation, set, workouts]);
return (
<View style={styles.container}>