Skip to content

Commit 788b98b

Browse files
Fix counting stopped at 00:00:01
1 parent 56f7cff commit 788b98b

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/views/room/Room.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,21 @@ const Room = (): JSX.Element => {
4747

4848
useEffect(() => {
4949

50-
// let _countdownTimerRef: NodeJS.Timeout | undefined = undefined;
51-
let _countdownTimerRef: NodeJS.Timeout | null = null;
52-
53-
if (isStarted && !_countdownTimerRef) {
50+
if (isStarted) {
5451

55-
_countdownTimerRef = setInterval(() => {
52+
const _countdownTimerRef = setInterval(() => {
5653
let leftUnix = moment(`1000-01-01 ${left}`).unix();
57-
const endUnix = moment('1000-01-01 00:00:00').unix();
5854

5955
leftUnix--;
6056

6157
const leftString = moment.unix(leftUnix).format('HH:mm:ss');
6258

6359
dispatch(countdownTimerSlices.setCountdownTimer({ left: leftString }));
6460

65-
if (leftUnix === endUnix) {
66-
dispatch(countdownTimerActions.stopCountdownTimer());
67-
}
68-
6961
}, 1000);
70-
} else if (_countdownTimerRef) clearInterval(_countdownTimerRef);
71-
72-
return (): void => {
73-
if (_countdownTimerRef) {
74-
clearInterval(_countdownTimerRef);
75-
_countdownTimerRef = null;
76-
}
77-
};
62+
63+
return () => { clearInterval(_countdownTimerRef); };
64+
}
7865

7966
}, [ isStarted, left, dispatch ]);
8067

0 commit comments

Comments
 (0)