File tree Expand file tree Collapse file tree
components/countdowntimer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ const CountdownTimer = () : JSX.Element => {
6666 InputLabelProps = { { shrink : true } }
6767 inputProps = { { step : '1' } }
6868 onChange = { ( e ) => {
69- dispatch ( countdownTimerActions . setCountdownTimer ( e . target . value ) ) ;
69+ dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( e . target . value ) ) ;
7070 } }
7171 onKeyDown = { ( e ) => {
7272 if ( remainingTime !== '00:00:00' ) {
@@ -88,7 +88,7 @@ const CountdownTimer = () : JSX.Element => {
8888 size = 'small'
8989 disabled = { ! isEnabled || ( isStarted || remainingTime === '00:00:00' ) }
9090 onClick = { ( ) => {
91- dispatch ( countdownTimerActions . setCountdownTimer ( '00:00:00' ) ) ;
91+ dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( '00:00:00' ) ) ;
9292 } }
9393 >
9494 < HighlightOffIcon />
Original file line number Diff line number Diff line change @@ -79,20 +79,21 @@ AppThunk<Promise<void>> => async (
7979 }
8080} ;
8181
82- export const setCountdownTimer = ( remainingTime : string ) :
82+ export const setCountdownTimerInitialTime = ( time : string ) :
8383AppThunk < Promise < void > > => async (
8484 dispatch ,
8585 getState ,
8686 { signalingService }
8787) : Promise < void > => {
88- logger . debug ( 'setCountdownTimer () [remainingTime :"%s"]' , remainingTime ) ;
88+ logger . debug ( 'setCountdownTimerInitialTime () [time :"%s"]' , time ) ;
8989
9090 try {
91- await signalingService . sendRequest ( 'moderator:setCountdownTimer' , { remainingTime } ) ;
91+
92+ signalingService . sendRequest ( 'moderator:setCountdownTimerInitialTime' , time ) ;
9293
93- dispatch ( countdownTimerActions . setCountdownTimer ( { remainingTime , isStarted : false } ) ) ;
94-
95- dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( { initialTime : remainingTime , isStarted : false } ) ) ;
94+ dispatch ( countdownTimerActions . setCountdownTimerRemainingTime ( time ) ) ;
95+
96+ dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( time ) ) ;
9697
9798 } catch ( error ) {
9899 logger . error ( 'setCountdownTimer() [error:"%o"]' , error ) ;
Original file line number Diff line number Diff line change @@ -82,8 +82,7 @@ export const joinRoom = (): AppThunk<Promise<void>> => async (
8282 dispatch ( lobbyPeersActions . addPeers ( lobbyPeers ) ) ;
8383 dispatch ( roomSessionsActions . addMessages ( { sessionId, messages : chatHistory } ) ) ;
8484 dispatch ( roomSessionsActions . addFiles ( { sessionId, files : fileHistory } ) ) ;
85- dispatch ( countdownTimerActions . setCountdownTimer ( countdownTimer ) ) ;
86- dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( countdownTimer ) ) ;
85+ dispatch ( countdownTimerActions . joinCountdownTimer ( countdownTimer ) ) ;
8786
8887 dispatch ( countdownTimer . isStarted ?
8988 countdownTimerActions . startCountdownTimer ( ) :
Original file line number Diff line number Diff line change @@ -52,25 +52,20 @@ const createCountdownTimerMiddleware = ({
5252 break ;
5353 }
5454
55- case 'moderator:hasSetCountdownTimer ' : {
55+ case 'moderator:settedCountdownTimerInitialTime ' : {
5656
57- const { remainingTime, initialTime, isStarted } = notification . data ;
58-
59- dispatch ( countdownTimerActions . setCountdownTimer (
60- { remainingTime, isStarted } ) ) ;
61-
62- dispatch ( countdownTimerActions . setCountdownTimerInitialTime (
63- { initialTime, isStarted } ) ) ;
57+ const time = notification . data ;
6458
59+ dispatch ( countdownTimerActions . setCountdownTimerInitialTime ( time ) ) ;
60+
6561 break ;
6662 }
6763
68- case 'moderator:updatedCountdownTimer ' : {
64+ case 'moderator:settedCountdownTimerRemainingTime ' : {
6965
70- const { remainingTime , isStarted } = notification . data ;
66+ const time = notification . data ;
7167
72- dispatch ( countdownTimerActions . setCountdownTimer (
73- { remainingTime, isStarted } ) ) ;
68+ dispatch ( countdownTimerActions . setCountdownTimerRemainingTime ( time ) ) ;
7469
7570 break ;
7671 }
Original file line number Diff line number Diff line change @@ -30,11 +30,21 @@ const countdownTimerSlice = createSlice({
3030 stopCountdownTimer : ( ( state ) => {
3131 state . isStarted = false ;
3232 } ) ,
33- setCountdownTimer : ( ( state , action : PayloadAction < any > ) => {
34- state . remainingTime = action . payload . remainingTime ;
33+ setCountdownTimerRemainingTime : ( ( state , action : PayloadAction < any > ) => {
34+
35+ const time = action . payload ;
36+
37+ state . remainingTime = time ;
3538 } ) ,
3639 setCountdownTimerInitialTime : ( ( state , action : PayloadAction < any > ) => {
40+
41+ const time = action . payload ;
42+
43+ state . initialTime = time ;
44+ } ) ,
45+ joinCountdownTimer : ( ( state , action : PayloadAction < any > ) => {
3746 state . initialTime = action . payload . initialTime ;
47+ state . remainingTime = action . payload . remainingTime ;
3848 } ) ,
3949 }
4050} ) ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ const Room = (): JSX.Element => {
5555
5656 const remainingTimeString = moment . unix ( remainingTimeUnix ) . format ( 'HH:mm:ss' ) ;
5757
58- dispatch ( countdownTimerSlices . setCountdownTimer ( { remainingTime : remainingTimeString } ) ) ;
58+ dispatch ( countdownTimerSlices . setCountdownTimerRemainingTime ( remainingTimeString ) ) ;
5959
6060 } , 1000 ) ;
6161
You can’t perform that action at this time.
0 commit comments