File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Fab from '@mui/material/Fab';
12
12
import { RootState } from '../../redux/store' ;
13
13
import SaveIcon from '@mui/icons-material/Save' ;
14
14
import { updateStylesheet } from '../../redux/reducers/slice/appStateSlice' ;
15
+ import { emitEvent } from '../../helperFunctions/socket' ;
15
16
16
17
const StylesEditor : React . FC < {
17
18
theme : string | null ;
@@ -21,6 +22,8 @@ const StylesEditor: React.FC<{
21
22
const stylesheet = useSelector (
22
23
( state : RootState ) => state . appState . stylesheet
23
24
) ;
25
+ const roomCode = useSelector ( ( store : RootState ) => store . roomSlice . roomCode ) ;
26
+
24
27
//sets state for what text is currently in the csseditor
25
28
const [ css , setCss ] = useState ( stylesheet ) ;
26
29
@@ -30,6 +33,10 @@ const StylesEditor: React.FC<{
30
33
const saveCss = ( e ) => {
31
34
e . preventDefault ( ) ;
32
35
dispatch ( updateStylesheet ( css ) ) ;
36
+ if ( roomCode ) {
37
+ emitEvent ( 'updateCSSAction' , roomCode , css ) ;
38
+ console . log ( 'emit updateCSSAction event is triggered in StylesEditor.tsx' ) ;
39
+ }
33
40
} ;
34
41
35
42
//handles changes in the ace editor
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import {
20
20
updateUseContext ,
21
21
updateCss ,
22
22
updateAttributes ,
23
- updateEvents
23
+ updateEvents ,
24
+ updateStylesheet
24
25
} from '../../redux/reducers/slice/appStateSlice' ;
25
26
import {
26
27
setRoomCode ,
@@ -122,7 +123,6 @@ const RoomsContainer = () => {
122
123
store . dispatch ( deleteChild ( deleteData ) ) ;
123
124
} ) ;
124
125
125
- //write out emitters for reach function inside of CusomizationPanel HandleSave//no need to pull the function into RoomsContainer
126
126
socket . on ( 'update data from server' , ( updateData : BottomPanelObj ) => {
127
127
console . log ( 'update data received from server' , updateData ) ;
128
128
store . dispatch ( updateStateUsed ( { stateUsedObj : updateData . stateUsedObj , contextParam : updateData . contextParam } ) ) ;
@@ -132,6 +132,11 @@ const RoomsContainer = () => {
132
132
store . dispatch ( updateEvents ( { events : updateData . events , contextParam : updateData . contextParam } ) ) ;
133
133
} ) ;
134
134
135
+ socket . on ( 'update css data from server' , ( cssData : object ) => {
136
+ console . log ( 'CSS data received from server' , cssData ) ;
137
+ store . dispatch ( updateStylesheet ( cssData ) ) ;
138
+ } ) ;
139
+
135
140
socket . on (
136
141
'item position data from server' ,
137
142
( itemPositionData : object ) => {
Original file line number Diff line number Diff line change @@ -207,7 +207,11 @@ io.on('connection', (client) => {
207
207
208
208
client . on ( 'updateChildAction' , ( roomCode : string , updateData : object ) => {
209
209
client . to ( roomCode ) . emit ( 'update data from server' , updateData ) ;
210
- console . log ( 'client received update from server!' )
210
+ } ) ;
211
+
212
+ client . on ( 'updateCSSAction' , ( roomCode : string , cssData : object ) => {
213
+ client . to ( roomCode ) . emit ( 'update css data from server' , cssData ) ;
214
+ console . log ( 'client received css update from server!' )
211
215
} ) ;
212
216
213
217
client . on (
You can’t perform that action at this time.
0 commit comments