diff --git a/components/Profile.tsx b/components/Profile.tsx index 069d56d..fef3bb4 100644 --- a/components/Profile.tsx +++ b/components/Profile.tsx @@ -71,8 +71,8 @@ const Profile: React.FC = ({ user, onLogout, lang, onLanguageChang setAllUsers(getUsers()); }; - const refreshExercises = () => { - setExercises(getExercises(user.id)); + const refreshExercises = async () => { + setExercises(await getExercises(user.id)); }; // Snackbar State diff --git a/components/Tracker.tsx b/components/Tracker.tsx index 6db25ad..d3d47d8 100644 --- a/components/Tracker.tsx +++ b/components/Tracker.tsx @@ -70,7 +70,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac useEffect(() => { const loadData = async () => { const exList = await getExercises(userId); - setExercises(exList.filter(e => !e.isArchived)); + setExercises(exList.filter(e => !e.isArchived || (activePlan && activePlan.steps.some(s => s.exerciseId === e.id)))); const planList = await getPlans(userId); setPlans(planList); @@ -81,7 +81,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac } }; loadData(); - }, [activeSession, userId, userWeight]); + }, [activeSession, userId, userWeight, activePlan]); // Timer Logic useEffect(() => { @@ -115,7 +115,7 @@ const Tracker: React.FC = ({ userId, userWeight, activeSession, ac } } } - }, [activeSession, activePlan, currentStepIndex, exercises]); + }, [activeSession, activePlan, currentStepIndex, exercises, selectedExercise]); useEffect(() => { const updateSelection = async () => {