Timer implemented. No working tests.

This commit is contained in:
AG
2025-12-10 23:07:31 +02:00
parent 3df4abba47
commit b86664816d
24 changed files with 806 additions and 116 deletions

View File

@@ -8,6 +8,7 @@ import { usePlanExecution } from '../../hooks/usePlanExecution';
import { useAuth } from '../../context/AuthContext';
import { useActiveWorkout } from '../../context/ActiveWorkoutContext';
import { useSession } from '../../context/SessionContext';
import { useRestTimer } from '../../hooks/useRestTimer';
export const useTracker = (props: any) => { // Props ignored/removed
const { currentUser } = useAuth();
@@ -61,6 +62,21 @@ export const useTracker = (props: any) => { // Props ignored/removed
const form = useWorkoutForm({ userId, onUpdateSet: handleUpdateSetWrapper });
const planExec = usePlanExecution({ activeSession, activePlan, exercises });
// Rest Timer Logic (Moved from ActiveSessionView to persist state)
const getTargetRestTime = () => {
if (activePlan) {
const currentStep = activePlan.steps[planExec.currentStepIndex];
if (currentStep && currentStep.restTimeSeconds) {
return currentStep.restTimeSeconds;
}
}
return currentUser?.profile?.restTimerDefault || 120;
};
const targetRestTime = getTargetRestTime();
const timer = useRestTimer({
defaultTime: targetRestTime
});
// Initial Data Load
useEffect(() => {
if (!userId) return;
@@ -247,7 +263,8 @@ export const useTracker = (props: any) => { // Props ignored/removed
onSessionEnd: endSession,
onSessionQuit: quitSession,
onRemoveSet: removeSet,
activeSession // Need this in view
activeSession, // Need this in view
timer // Expose timer to views
};
};