File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -47,34 +47,21 @@ const Room = (): JSX.Element => {
47
47
48
48
useEffect ( ( ) => {
49
49
50
- // let _countdownTimerRef: NodeJS.Timeout | undefined = undefined;
51
- let _countdownTimerRef : NodeJS . Timeout | null = null ;
52
-
53
- if ( isStarted && ! _countdownTimerRef ) {
50
+ if ( isStarted ) {
54
51
55
- _countdownTimerRef = setInterval ( ( ) => {
52
+ const _countdownTimerRef = setInterval ( ( ) => {
56
53
let leftUnix = moment ( `1000-01-01 ${ left } ` ) . unix ( ) ;
57
- const endUnix = moment ( '1000-01-01 00:00:00' ) . unix ( ) ;
58
54
59
55
leftUnix -- ;
60
56
61
57
const leftString = moment . unix ( leftUnix ) . format ( 'HH:mm:ss' ) ;
62
58
63
59
dispatch ( countdownTimerSlices . setCountdownTimer ( { left : leftString } ) ) ;
64
60
65
- if ( leftUnix === endUnix ) {
66
- dispatch ( countdownTimerActions . stopCountdownTimer ( ) ) ;
67
- }
68
-
69
61
} , 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
+ }
78
65
79
66
} , [ isStarted , left , dispatch ] ) ;
80
67
You can’t perform that action at this time.
0 commit comments