Skip to content

Commit ca5d849

Browse files
committed
bug fix in userList
1 parent fe3f54f commit ca5d849

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
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
/>

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)