Skip to content

Commit 6e270e4

Browse files
committed
fix time remaining
1 parent 248b538 commit 6e270e4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/components/workout/WorkoutManager.tsx

+10-12
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export class WorkoutManager implements WorkoutManagerI {
139139
return this._sessionId;
140140
}
141141

142+
computeTimeLeft() {
143+
if (this._timer?.remainingTime) {
144+
this._timeLeft = this._timeFromBeginningOfSet + this._timer.remainingTime;
145+
} else {
146+
this._timeLeft = this.timeFromBeginningOfSet;
147+
}
148+
}
149+
142150
async startWorkout() {
143151
if (this.started) return;
144152
if (!this.ready) return;
@@ -255,15 +263,7 @@ export class WorkoutManager implements WorkoutManagerI {
255263
),
256264
);
257265

258-
if (this._timer?.totalTime) {
259-
this._timeLeft =
260-
this._timeFromBeginningOfSet -
261-
(this._timer.totalTime - this._timer.remainingTime);
262-
} else {
263-
this._timeLeft = this.timeFromBeginningOfSet;
264-
}
265-
266-
// this._timeLeft = this._timeFromBeginningOfSet;
266+
this.computeTimeLeft();
267267
this._playedThreeSecondSound = false;
268268
await this.refresh();
269269
}
@@ -285,9 +285,7 @@ export class WorkoutManager implements WorkoutManagerI {
285285
onTimerTick() {
286286
if (this._timer && this.dispatch) {
287287
const state = this._timer.state();
288-
this._timeLeft =
289-
this._timeFromBeginningOfSet -
290-
(this._timer.totalTime - this._timer.remainingTime);
288+
this.computeTimeLeft();
291289
if (state.remainingTime <= 4000 && !this.playedThreeSecondSound) {
292290
if (soundPlayer) {
293291
soundPlayer.play();

0 commit comments

Comments
 (0)