Timer implemented. No working tests.
This commit is contained in:
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user