From c959bbc25547a1ce54d60374e248c971998622a7 Mon Sep 17 00:00:00 2001 From: dank074 Date: Tue, 19 Oct 2021 16:41:13 -0500 Subject: [PATCH] fix mod tools packet listener --- .../mod-tools/views/room-chatlog/ModToolsChatlogView.tsx | 4 ++-- src/views/mod-tools/views/room/ModToolsRoomView.tsx | 4 +++- .../mod-tools/views/user-chatlog/ModToolsUserChatlogView.tsx | 4 ++-- src/views/mod-tools/views/user/ModToolsUserView.tsx | 5 ++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/views/mod-tools/views/room-chatlog/ModToolsChatlogView.tsx b/src/views/mod-tools/views/room-chatlog/ModToolsChatlogView.tsx index b1799000..2c23264f 100644 --- a/src/views/mod-tools/views/room-chatlog/ModToolsChatlogView.tsx +++ b/src/views/mod-tools/views/room-chatlog/ModToolsChatlogView.tsx @@ -20,10 +20,10 @@ export const ModToolsChatlogView: FC = props => { const parser = event.getParser(); - if(!parser) return; + if(!parser || parser.data.roomId !== roomId) return; setRoomChatlog(parser.data); - }, [setRoomChatlog]); + }, [roomId, setRoomChatlog]); CreateMessageHook(ModtoolRoomChatlogEvent, onModtoolRoomChatlogEvent); diff --git a/src/views/mod-tools/views/room/ModToolsRoomView.tsx b/src/views/mod-tools/views/room/ModToolsRoomView.tsx index a6bd2a7b..31d8459f 100644 --- a/src/views/mod-tools/views/room/ModToolsRoomView.tsx +++ b/src/views/mod-tools/views/room/ModToolsRoomView.tsx @@ -32,13 +32,15 @@ export const ModToolsRoomView: FC = props => { const parser = event.getParser(); + if(!parser || parser.id !== roomId) return; + setLoadedRoomId(parser.id); setName(parser.name); setOwnerId(parser.ownerId); setOwnerName(parser.ownerName); setOwnerInRoom(parser.ownerInRoom); setUsersInRoom(parser.playerAmount); - }, [ setLoadedRoomId, setName, setOwnerId, setOwnerName, setOwnerInRoom, setUsersInRoom ]); + }, [ setLoadedRoomId, setName, setOwnerId, setOwnerName, setOwnerInRoom, setUsersInRoom, roomId ]); CreateMessageHook(ModtoolRoomInfoEvent, onModtoolRoomInfoEvent); diff --git a/src/views/mod-tools/views/user-chatlog/ModToolsUserChatlogView.tsx b/src/views/mod-tools/views/user-chatlog/ModToolsUserChatlogView.tsx index 23b1590d..d2ca9bd0 100644 --- a/src/views/mod-tools/views/user-chatlog/ModToolsUserChatlogView.tsx +++ b/src/views/mod-tools/views/user-chatlog/ModToolsUserChatlogView.tsx @@ -20,11 +20,11 @@ export const ModToolsUserChatlogView: FC = props = { const parser = event.getParser(); - if(!parser) return; + if(!parser || parser.userId !== userId) return; setUsername(parser.username); setUserChatlog(parser.roomVisits); - }, [setUsername, setUserChatlog]); + }, [setUsername, setUserChatlog, userId]); CreateMessageHook(ModtoolUserChatlogEvent, onModtoolUserChatlogEvent); diff --git a/src/views/mod-tools/views/user/ModToolsUserView.tsx b/src/views/mod-tools/views/user/ModToolsUserView.tsx index 03c109fa..373bd2df 100644 --- a/src/views/mod-tools/views/user/ModToolsUserView.tsx +++ b/src/views/mod-tools/views/user/ModToolsUserView.tsx @@ -21,11 +21,10 @@ export const ModToolsUserView: FC = props => { const parser = event.getParser(); - if(!parser) return; + if(!parser || parser.data.userId !== userId) return; - console.log(parser); setUserInfo(parser.data); - }, [setUserInfo]); + }, [setUserInfo, userId]); CreateMessageHook(ModtoolUserInfoEvent, onModtoolUserInfoEvent);