Skip to content

Commit d452a07

Browse files
committed
chatroom function clean up and improvement
1 parent 17d20b5 commit d452a07

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const BottomTabs = (props): JSX.Element => {
3131
const state = useSelector((store: RootState) => store.appState);
3232
const contextParam = useSelector((store: RootState) => store.contextSlice);
3333
const collaborationRoom = useSelector((store: RootState) => store.roomSlice);
34-
// {roomCode: '', userName: '', userList: Array(0), userJoined: false}
3534

3635
const [tab, setTab] = useState(0);
3736
const classes = useStyles();
@@ -60,7 +59,7 @@ const BottomTabs = (props): JSX.Element => {
6059
zIndex: 1,
6160
borderTop: '2px solid grey'
6261
}}
63-
onMouseOver={() => {
62+
onClick={() => {
6463
props.setBottomShow(true);
6564
}}
6665
>

app/src/components/bottom/chatRoom.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { RootState } from '../../redux/store';
44
import { emitEvent } from '../../helperFunctions/socket';
55

66
const Chatroom = (props): JSX.Element => {
7-
const collaborationRoom = useSelector((store: RootState) => store.roomSlice);
7+
const nickName = useSelector((store: RootState) => store.roomSlice.userName);
8+
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
89

910
const newMessage = useSelector(
1011
(store: RootState) => store.roomSlice.newMessage
@@ -14,9 +15,6 @@ const Chatroom = (props): JSX.Element => {
1415
(store: RootState) => store.roomSlice.userChange
1516
);
1617

17-
const nickName = collaborationRoom.userName;
18-
const roomCode = collaborationRoom.roomCode;
19-
2018
const wrapperStyles = {
2119
border: `2px solid #f2fbf8`,
2220
borderRadius: '8px',
@@ -93,8 +91,8 @@ const Chatroom = (props): JSX.Element => {
9391
const messageElement = document.createElement('div');
9492
messageElement.innerText =
9593
userChange.status === 'JOIN'
96-
? `${userChange.nickName} joined the chatroom`
97-
: `${userChange.nickName} left the chatroom`;
94+
? `${userChange.nickName} joined the chat room`
95+
: `${userChange.nickName} left the chat room`;
9896
messageElement.style.color = 'yellow';
9997
messageContainer.append(messageElement);
10098
}, [userChange]);
@@ -106,10 +104,10 @@ const Chatroom = (props): JSX.Element => {
106104
>
107105
<div className="roomInfo" style={{ paddingLeft: '70px' }}>
108106
<p>Current room: {roomCode}</p>
109-
<p>Your Nickname: {nickName}</p>
107+
<p>Your nickname: {nickName}</p>
110108
</div>
111109
<div style={{ justifyContent: 'center', display: 'flex', height: '80%' }}>
112-
<div id="message-container" style={{ ...wrapperStyles }}></div>
110+
<div id="message-container" style={wrapperStyles}></div>
113111
</div>
114112
<form
115113
id="send-container"

app/src/redux/reducers/slice/roomSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { createSlice } from '@reduxjs/toolkit';
44
const initialState = {
55
roomCode: '',
66
userName: '',
7-
newMessage: { nickName: '', message: '' },
87
userList: [],
98
userJoined: false,
9+
newMessage: { nickName: '', message: '' },
1010
userChange: { nickName: '', status: '' }
1111
};
1212

0 commit comments

Comments
 (0)