From 9ae311b94ab29cc8fc0e3ffbbe1799801ed5e8d5 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Mon, 4 Sep 2023 13:59:35 +1200 Subject: [PATCH] Toggle selecting all for Plans and Workouts --- PlanList.tsx | 3 ++- WorkoutList.tsx | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PlanList.tsx b/PlanList.tsx index d7bf20d..9fae89f 100644 --- a/PlanList.tsx +++ b/PlanList.tsx @@ -86,8 +86,9 @@ export default function PlanList() { const select = useCallback(() => { if (!plans) return; + if (ids.length === plans.length) return setIds([]); setIds(plans.map((plan) => plan.id)); - }, [plans]); + }, [plans, ids.length]); return ( <> diff --git a/WorkoutList.tsx b/WorkoutList.tsx index 27173f2..8f4baa4 100644 --- a/WorkoutList.tsx +++ b/WorkoutList.tsx @@ -117,6 +117,7 @@ export default function WorkoutList() { const select = () => { if (!workouts) return; + if (names.length === workouts.length) return setNames([]); setNames(workouts.map((workout) => workout.name)); };