Skip to content

Commit 20c78f1

Browse files
authored
Merge pull request #22 from oslabs-beta/liz-userListbug
Bug Fix in UserList
2 parents 93bab5d + 9d3982a commit 20c78f1

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

app/src/components/left/RoomsContainer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,10 @@ const RoomsContainer = () => {
386386
</Typography>
387387
{userJoined ? (
388388
<>
389-
<Typography variant="h6" color="#898a8b">
389+
<Typography
390+
variant="h6"
391+
color={userColors[userList.indexOf(userName)]}
392+
>
390393
Nickname: {userName}
391394
</Typography>
392395
<Typography
@@ -429,7 +432,7 @@ const RoomsContainer = () => {
429432
>
430433
<ListItemText
431434
primary={`${index + 1}. ${
432-
index === 0 ? `${user.userName} (host)` : user.userName
435+
index === 0 ? `${user} (host)` : user
433436
}`}
434437
style={{ color: userColors[userList.indexOf(user)] }}
435438
/>

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ const roomSlice = createSlice({
2828
setMessages: (state, action) => {
2929
state.messages = [...state.messages, action.payload];
3030
},
31-
setEmptyMessages: (state, action) => {
32-
state.messages = [];
33-
},
3431
setPassword: (state, action) => {
3532
state.password = action.payload;
3633
}
@@ -43,7 +40,6 @@ export const {
4340
setUserList,
4441
setUserJoined,
4542
setMessages,
46-
setEmptyMessages,
4743
setPassword
4844
} = roomSlice.actions;
4945

server/server.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,13 @@ io.on('connection', (client) => {
159159

160160
if (newClientResponse[0].status === 'confirmed') {
161161
client.join(roomCode); //client joining a room
162+
const usernNames = Object.values(roomLists[roomCode]).map(
163+
(el) => el['userName']
164+
);
162165
io.to(roomCode).emit(
163166
'updateUserList',
164167
{
165-
userList: Object.values(roomLists[roomCode])
168+
userList: usernNames
166169
} // send updated userList to all users in room
167170
);
168171
io.to(roomCode).emit('new chat message', {
@@ -197,8 +200,11 @@ io.on('connection', (client) => {
197200
delete roomLists[roomCode];
198201
} else {
199202
//else emit updated user list
203+
const usernNames = Object.values(roomLists[roomCode]).map(
204+
(el) => el['userName']
205+
);
200206
io.to(roomCode).emit('updateUserList', {
201-
userList: Object.values(roomLists[roomCode])
207+
userList: usernNames
202208
});
203209
io.to(roomCode).emit('new chat message', {
204210
userName,

0 commit comments

Comments
 (0)