@@ -13,7 +13,6 @@ import { cooperativeStyle } from '../../redux/reducers/slice/styleSlice';
13
13
// websocket front end starts here
14
14
import { io } from 'socket.io-client' ;
15
15
import store from '../../redux/store' ;
16
- import { toggleDarkMode } from '../../redux/reducers/slice/darkModeSlice' ;
17
16
//pasted from navbarbuttons
18
17
import debounce from '../../../../node_modules/lodash/debounce.js' ;
19
18
@@ -80,36 +79,36 @@ const RoomsContainer = () => {
80
79
function handleUserEnteredRoom ( roomCode ) {
81
80
initSocketConnection ( roomCode ) ;
82
81
}
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 ( ) ;
85
84
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 ;
90
89
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
+ }
95
94
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 ) ;
107
106
108
- store . subscribe ( ( ) => {
109
- if ( socket ) {
110
- handleStoreChange ( ) ;
111
- }
112
- } ) ;
107
+ store . subscribe ( ( ) => {
108
+ if ( socket ) {
109
+ handleStoreChange ( ) ;
110
+ }
111
+ } ) ;
113
112
114
113
function joinRoom ( ) {
115
114
dispatch ( changeRoom ( roomCode ) ) ;
0 commit comments