File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -386,7 +386,10 @@ const RoomsContainer = () => {
386
386
</ Typography >
387
387
{ userJoined ? (
388
388
< >
389
- < Typography variant = "h6" color = "#898a8b" >
389
+ < Typography
390
+ variant = "h6"
391
+ color = { userColors [ userList . indexOf ( userName ) ] }
392
+ >
390
393
Nickname: { userName }
391
394
</ Typography >
392
395
< Typography
@@ -429,7 +432,7 @@ const RoomsContainer = () => {
429
432
>
430
433
< ListItemText
431
434
primary = { `${ index + 1 } . ${
432
- index === 0 ? `${ user . userName } (host)` : user . userName
435
+ index === 0 ? `${ user } (host)` : user
433
436
} `}
434
437
style = { { color : userColors [ userList . indexOf ( user ) ] } }
435
438
/>
Original file line number Diff line number Diff line change @@ -28,9 +28,6 @@ const roomSlice = createSlice({
28
28
setMessages : ( state , action ) => {
29
29
state . messages = [ ...state . messages , action . payload ] ;
30
30
} ,
31
- setEmptyMessages : ( state , action ) => {
32
- state . messages = [ ] ;
33
- } ,
34
31
setPassword : ( state , action ) => {
35
32
state . password = action . payload ;
36
33
}
@@ -43,7 +40,6 @@ export const {
43
40
setUserList,
44
41
setUserJoined,
45
42
setMessages,
46
- setEmptyMessages,
47
43
setPassword
48
44
} = roomSlice . actions ;
49
45
Original file line number Diff line number Diff line change @@ -159,10 +159,13 @@ io.on('connection', (client) => {
159
159
160
160
if ( newClientResponse [ 0 ] . status === 'confirmed' ) {
161
161
client . join ( roomCode ) ; //client joining a room
162
+ const usernNames = Object . values ( roomLists [ roomCode ] ) . map (
163
+ ( el ) => el [ 'userName' ]
164
+ ) ;
162
165
io . to ( roomCode ) . emit (
163
166
'updateUserList' ,
164
167
{
165
- userList : Object . values ( roomLists [ roomCode ] )
168
+ userList : usernNames
166
169
} // send updated userList to all users in room
167
170
) ;
168
171
io . to ( roomCode ) . emit ( 'new chat message' , {
@@ -197,8 +200,11 @@ io.on('connection', (client) => {
197
200
delete roomLists [ roomCode ] ;
198
201
} else {
199
202
//else emit updated user list
203
+ const usernNames = Object . values ( roomLists [ roomCode ] ) . map (
204
+ ( el ) => el [ 'userName' ]
205
+ ) ;
200
206
io . to ( roomCode ) . emit ( 'updateUserList' , {
201
- userList : Object . values ( roomLists [ roomCode ] )
207
+ userList : usernNames
202
208
} ) ;
203
209
io . to ( roomCode ) . emit ( 'new chat message' , {
204
210
userName,
You can’t perform that action at this time.
0 commit comments