Skip to content

Commit

Permalink
added finish step
Browse files Browse the repository at this point in the history
  • Loading branch information
andorsk committed May 6, 2024
1 parent f8c699e commit f6f6ce3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
7 changes: 3 additions & 4 deletions src/components/workout/WorkoutManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,12 @@ export class WorkoutManager implements WorkoutManagerI {
throw new Error("Invalid step set. Must be valid and session created.");
}

if (this._currentStep >= this.workout.steps.length - 1) {
this._set = true;
this._currentStep = step;
if (step >= this.workout.steps.length - 1) {
await this.endWorkout();
return;
}

this._set = true;
this._currentStep = step;
if (this._timer && this._workout) {
this._timer.setTime(this._workout?.steps[step]?.duration);
}
Expand Down
29 changes: 1 addition & 28 deletions src/pages/PlayScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function StepView() {
if (workoutState.manager?.workout?.steps.length === 0) {
return;
}
console.log("setting step to", index);
workoutState.manager?.setStep(index);
};

Expand All @@ -52,33 +53,6 @@ function StepView() {
);
}, [workoutState]);

// useEffect(() => {
// const h = async (workoutState: WorkoutState, web5state: Web5State) => {
// if (
// workoutState?.manager?.started &&
// web5state?.loaded &&
// !isUpdating &&
// workoutState.manager.workout &&
// web5state.web5
// ) {
// try {
// await updateSession(workoutState?.manager?.workout, web5state.web5);
// } catch (e) {
// console.error("failed to get session", e);
// }
// }
// };
// // TODO. Fix
// // @ts-ignore
// h(workoutState, web5state);
// }, [
// workoutState.manager.currentStep,
// workoutState.manager.isWorkoutActive,
// workoutState.manager.workout._completed,
// workoutState.manager.started,
// workoutState.manager.ready,
// ]);

const whiteListedNames = [
"Rest Between Sets",
"Cool Down",
Expand Down Expand Up @@ -136,7 +110,6 @@ function Footer() {
workoutState?.manager.workout?.steps[workoutState?.manager.currentStep],
);
if (!workoutState.manager.ready) {
alert("no workout set. routing you to select first");
router.push("/");
}
}, [workoutState]);
Expand Down

0 comments on commit f6f6ce3

Please sign in to comment.