Skip to content

Commit a2a134f

Browse files
committed
Merge branch 'dev' into brian
2 parents 49ec461 + 156ded8 commit a2a134f

File tree

9 files changed

+160
-104
lines changed

9 files changed

+160
-104
lines changed

app/src/components/bottom/BottomPanel.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect, useRef } from 'react';
22
import BottomTabs from './BottomTabs';
3+
import { ExpandLess, ExpandMore } from '@mui/icons-material';
34

45
const BottomPanel = (props): JSX.Element => {
56
let y: number = 0;
@@ -15,18 +16,17 @@ const BottomPanel = (props): JSX.Element => {
1516
//Start listeners when the user clicks the bottom panel tab
1617
document.addEventListener('mousemove', mouseMoveHandler);
1718
document.addEventListener('mouseup', mouseUpHandler);
18-
window.addEventListener('message', handleIframeMessage);//listens for messages from the iframe when the mouse is over it
19+
window.addEventListener('message', handleIframeMessage); //listens for messages from the iframe when the mouse is over it
1920
};
20-
21+
2122
//Interpret the messages from the iframe
2223
const handleIframeMessage = (e) => {
2324
if (e.data === 'iframeMouseUp') {
2425
mouseUpHandler();
25-
}else if(e.data.type === 'iframeMouseMove'){
26-
mouseMoveHandler(e.data)
26+
} else if (e.data.type === 'iframeMouseMove') {
27+
mouseMoveHandler(e.data);
2728
}
28-
}
29-
29+
};
3030

3131
const mouseMoveHandler = function (e: MouseEvent): void {
3232
// How far the mouse has been moved
@@ -54,12 +54,21 @@ const BottomPanel = (props): JSX.Element => {
5454

5555
return (
5656
<>
57-
<div className="bottom-panel" id="resize" ref={node}>
58-
<div id="resize-drag" onMouseDown={mouseDownHandler} tabIndex={0}>
59-
......
57+
<div className="bottom-panel" id="resize" ref={node}>
58+
<div
59+
id="resize-drag"
60+
onMouseDown={mouseDownHandler}
61+
onClick={() => props.setBottomShow(true)}
62+
tabIndex={0}
63+
>
64+
{props.bottomShow ? <ExpandMore /> : <ExpandLess />}
65+
</div>
66+
<BottomTabs
67+
setBottomShow={props.setBottomShow}
68+
isThemeLight={props.isThemeLight}
69+
/>
6070
</div>
61-
<BottomTabs setBottomShow = {props.setBottomShow} isThemeLight={props.isThemeLight} />
62-
</div></>
71+
</>
6372
);
6473
};
6574

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const BottomTabs = (props): JSX.Element => {
5757
zIndex: 1,
5858
borderTop: '2px solid grey'
5959
}}
60-
onMouseOver={() => {
60+
onClick={() => {
6161
props.setBottomShow(true);
6262
}}
6363
>

app/src/components/left/RoomsContainer.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
addPassedInProps,
2929
deletePassedInProps,
3030
deleteElement,
31+
resetAllState,
3132
updateStylesheet
3233
} from '../../redux/reducers/slice/appStateSlice';
3334
import {
@@ -132,6 +133,11 @@ const RoomsContainer = () => {
132133
}
133134
);
134135

136+
// dispatch clear canvas action to local state when the host of the room has clear canvas
137+
socket.on('clear canvas from server', () => {
138+
store.dispatch(resetAllState());
139+
});
140+
135141
// dispatch all updates to local state when another user has saved from Bottom Panel
136142
socket.on('update data from server', (updateData: BottomPanelObj) => {
137143
// console.log('update data received from server', updateData);

app/src/components/top/NavBarButtons.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { resetAllState } from '../../redux/reducers/slice/appStateSlice';
2121
import { setStyle } from '../../redux/reducers/slice/styleSlice';
2222
import store from '../../redux/store';
2323
import withStyles from '@mui/styles/withStyles';
24+
import { emitEvent } from '../../helperFunctions/socket';
2425

2526
const { API_BASE_URL } = config;
2627

@@ -97,6 +98,8 @@ function navbarDropDown(props) {
9798
// state: store.appState
9899
// }));
99100
const state = useSelector((store: RootState) => store.appState);
101+
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
102+
const userName = useSelector((store: RootState) => store.roomSlice.userName);
100103

101104
const closeModal = () => setModal('');
102105
const handleClick = (event) => {
@@ -106,7 +109,8 @@ function navbarDropDown(props) {
106109
const clearWorkspace = () => {
107110
// Reset state for project to initial state
108111
const resetState = () => {
109-
dispatch(resetAllState());
112+
if (roomCode) emitEvent('clearCanvasAction', roomCode, userName);
113+
else dispatch(resetAllState());
110114
};
111115
// Set modal options
112116
const children = (
@@ -129,6 +133,7 @@ function navbarDropDown(props) {
129133
</ListItem>
130134
</List>
131135
);
136+
132137
// Create modal
133138
setModal(
134139
createModal({

app/src/containers/MainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const MainContainer = (props): JSX.Element => {
119119
</div>
120120
<div className={showPanel} ref={ref}>
121121
<BottomPanel
122+
bottomShow={bottomShow}
122123
setBottomShow={setBottomShow}
123124
isThemeLight={props.isThemeLight}
124125
/>

app/src/redux/store.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ import { configureStore } from '@reduxjs/toolkit';
33
// Import of combined reducers in rootReducer
44
import rootReducer from './reducers/rootReducer';
55

6-
/*
7-
// Define the root state type based on the rootReducer
8-
export type RootState = ReturnType<typeof rootReducer>;
9-
10-
// Define the type of the Redux store
11-
export type AppStore = Store<RootState>;
12-
*/
13-
146
const store = configureStore({
157
reducer: rootReducer,
168
middleware: (getDefaultMiddleware) => {

0 commit comments

Comments
 (0)