Skip to content

Commit 457b324

Browse files
committed
further TS changes
1 parent 55ba1c2 commit 457b324

File tree

5 files changed

+37
-63
lines changed

5 files changed

+37
-63
lines changed

app/src/components/left/RoomsContainer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { io } from 'socket.io-client';
2323
import store from '../../redux/store';
2424
//pasted from navbarbuttons
2525
import debounce from '../../../../node_modules/lodash/debounce.js';
26+
import { deepEqual } from 'assert';
2627

2728
// // for websockets
2829
// // Part - join room and room code functionality
@@ -92,8 +93,9 @@ const RoomsContainer = () => {
9293
const newState = store.getState();
9394
const roomCode = newState.roomSlice.roomCode;
9495

95-
if (newState !== previousState) {
96+
if (JSON.stringify(newState) !== JSON.stringify(previousState)) {
9697
// Send the current state to the server
98+
console.log('emit state unequal');
9799
socket.emit('custom-event', JSON.stringify(newState), roomCode);
98100
previousState = newState;
99101
}
@@ -106,7 +108,7 @@ const RoomsContainer = () => {
106108
});
107109

108110
function joinRoom() {
109-
if (userList.length !== 0) setUserList([]); //edge case check if userList not empty.
111+
if (userList.length !== 0) dispatch(setUserList([])); //edge case check if userList not empty.
110112
handleUserEnteredRoom(roomCode); // Call handleUserEnteredRoom when joining a room
111113
dispatch(setRoomCode(roomCode));
112114
dispatch(setUserJoined(true)); //setting joined room to true for rendering leave room button

app/src/components/main/Canvas.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function Canvas(props: {}): JSX.Element {
121121
});
122122

123123
// Styling for Canvas
124-
const defaultCanvasStyle = {
124+
const defaultCanvasStyle: React.CSSProperties = {
125125
width: '100%',
126126
minHeight: '100%',
127127
backgroundColor: isOver ? '#191919' : '#191919',
@@ -134,7 +134,10 @@ function Canvas(props: {}): JSX.Element {
134134
// The render children function renders all direct children of a given component
135135
// Direct children are draggable/clickable
136136

137-
const canvasStyle = combineStyles(defaultCanvasStyle, currentComponent.style);
137+
const canvasStyle: React.CSSProperties = combineStyles(
138+
defaultCanvasStyle,
139+
currentComponent.style
140+
);
138141

139142
return (
140143
<div

app/src/components/main/CanvasContainer.tsx

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,45 @@ import { Button } from '@mui/material';
99
// The CanvasContainer sets the boundaries on the width/height of the canvas
1010
function CanvasContainer(props): JSX.Element {
1111
const [theme, setTheme] = useState('solarized_light'); // theme for ACE editor, taken from BottomTabs
12-
const { state } = useSelector(
13-
(store: RootState) => ({
14-
state: store.appState,
15-
})
16-
);
12+
const { state } = useSelector((store: RootState) => ({
13+
state: store.appState
14+
}));
1715
const dispatch = useDispatch();
1816

1917
// onClickCodePreview swaps the rendered component from the canvas to the code preview editor
2018
const onClickCodePreview = () => {
2119
dispatch(toggleCodePreview());
22-
}
20+
};
2321

24-
const canvasContainerStyle = {
22+
const canvasContainerStyle: React.CSSProperties = {
2523
width: '100%',
2624
backgroundColor: 'lightgrey',
2725
border: '2px solid grey',
2826
borderBottom: 'none',
29-
overflow: 'auto',
27+
overflow: 'auto'
3028
};
3129

32-
const codePreviewStyle = {
30+
const codePreviewStyle: React.CSSProperties = {
3331
position: 'fixed',
3432
width: 'max-content',
3533
height: 'max-content',
36-
bottom: '100px',
37-
right: '51vw',
34+
bottom: '100px',
35+
right: '51vw',
3836
textAlign: 'center',
39-
color: '#ffffff',
37+
color: '#ffffff',
4038
backgroundColor: '#151515',
4139
zIndex: 0,
4240
border: '2px solid #186BB4'
43-
44-
45-
4641
} as const;
4742

4843
return (
4944
<div style={canvasContainerStyle}>
50-
{state.codePreview && <CodePreview theme={theme} setTheme={setTheme}/>}
51-
{!state.codePreview && <Canvas isThemeLight={props.isThemeLight}/>}
52-
53-
<Button
54-
style={codePreviewStyle}
55-
onClick={onClickCodePreview}
56-
>
45+
{state.codePreview && <CodePreview theme={theme} setTheme={setTheme} />}
46+
{!state.codePreview && <Canvas isThemeLight={props.isThemeLight} />}
47+
48+
<Button style={codePreviewStyle} onClick={onClickCodePreview}>
5749
Code Preview
5850
</Button>
59-
6051
</div>
6152
);
6253
}

package-lock.json

Lines changed: 13 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"cookie-parser": "^1.4.6",
136136
"cors": "^2.8.5",
137137
"d3": "^7.6.1",
138+
"deep-equal": "^2.2.3",
138139
"dotenv": "^16.0.1",
139140
"electron-debug": "^3.2.0",
140141
"electron-devtools-installer": "^3.2.0",

0 commit comments

Comments
 (0)