@@ -13,7 +13,6 @@ import { cooperativeStyle } from '../../redux/reducers/slice/styleSlice';
1313// websocket front end starts here
1414import { io } from 'socket.io-client' ;
1515import store from '../../redux/store' ;
16- import { toggleDarkMode } from '../../redux/reducers/slice/darkModeSlice' ;
1716//pasted from navbarbuttons
1817import debounce from '../../../../node_modules/lodash/debounce.js' ;
1918
@@ -80,36 +79,36 @@ const RoomsContainer = () => {
8079 function handleUserEnteredRoom ( roomCode ) {
8180 initSocketConnection ( roomCode ) ;
8281 }
83- //line 83-113 was pasted in from NavBarButtons
84- let previousState = store . getState ( ) ;
82+ //line 83-113 was pasted in from NavBarButtons
83+ let previousState = store . getState ( ) ;
8584
86- // sending info to backend whenever the redux store changes
87- const handleStoreChange = debounce ( ( ) => {
88- const newState = store . getState ( ) ;
89- const roomCode = newState . roomCodeSlice . roomCode ;
85+ // sending info to backend whenever the redux store changes
86+ const handleStoreChange = debounce ( ( ) => {
87+ const newState = store . getState ( ) ;
88+ const roomCode = newState . roomCodeSlice . roomCode ;
9089
91- if ( roomCode !== '' ) {
92- // Emit the current room code
93- socket . emit ( 'room-code' , roomCode ) ;
94- }
90+ if ( roomCode !== '' ) {
91+ // Emit the current room code
92+ socket . emit ( 'room-code' , roomCode ) ;
93+ }
9594
96- if ( newState !== previousState ) {
97- // Send the current state to the server
98- socket . emit (
99- 'custom-event' ,
100- 'sent from front-end' ,
101- JSON . stringify ( newState ) ,
102- roomCode
103- ) ;
104- previousState = newState ;
105- }
106- } , 100 ) ;
95+ if ( newState !== previousState ) {
96+ // Send the current state to the server
97+ socket . emit (
98+ 'custom-event' ,
99+ 'sent from front-end' ,
100+ JSON . stringify ( newState ) ,
101+ roomCode
102+ ) ;
103+ previousState = newState ;
104+ }
105+ } , 100 ) ;
107106
108- store . subscribe ( ( ) => {
109- if ( socket ) {
110- handleStoreChange ( ) ;
111- }
112- } ) ;
107+ store . subscribe ( ( ) => {
108+ if ( socket ) {
109+ handleStoreChange ( ) ;
110+ }
111+ } ) ;
113112
114113 function joinRoom ( ) {
115114 dispatch ( changeRoom ( roomCode ) ) ;
0 commit comments