Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-06-09 20:43:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
77863a8424d3e8a7b56866a6d48b2356825f5b30
77863a84
1 parent
dd7529d2
handleUpdateRoomUser에 state가 updated인 경우 추가
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
web/src/pages/Room.tsx
web/src/pages/Room.tsx
View file @
77863a8
...
...
@@ -31,7 +31,6 @@ export const Room: React.FC = () => {
const handleUpdateRoomUser = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type == MessageType.ROOM_USER_UPDATE) {
const data = rawMessage.message as UpdateRoomUser;
console.log(data);
if (data.state == 'removed') {
const newUsers = roomData.users;
const index = newUsers.indexOf(data.user);
...
...
@@ -44,7 +43,19 @@ export const Room: React.FC = () => {
...roomData,
users: newUsers
});
} else if (data.state == 'added') {
} else if (data.state === 'updated') {
const newUsers = roomData.users;
const index = newUsers.findIndex(x => x.username === data.user.username);
if (index < 0) {
console.log('존재하지 않는 유저를 업데이트 시도');
} else {
newUsers[index] = data.user;
}
setRoomData({
...roomData,
users: newUsers
})
} else {
setRoomData({
...roomData,
users: [data.user, ...roomData.users]
...
...
Please
register
or
login
to post a comment