From 2291b419b55bb701cda9f630f78f20a15a7e95cc Mon Sep 17 00:00:00 2001 From: SohamRatnaparkhi Date: Fri, 6 Oct 2023 10:55:03 +0530 Subject: [PATCH] fix: chat bugs Signed-off-by: SohamRatnaparkhi --- frontend/app/meeting/lobby/[slug]/page.jsx | 17 ++++++++++++----- .../meeting/room/[slug]/components/ChatBox.jsx | 10 +++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/frontend/app/meeting/lobby/[slug]/page.jsx b/frontend/app/meeting/lobby/[slug]/page.jsx index 2d3b8dc7..86f3550b 100644 --- a/frontend/app/meeting/lobby/[slug]/page.jsx +++ b/frontend/app/meeting/lobby/[slug]/page.jsx @@ -36,7 +36,7 @@ const MeetLobby = ({ params }) => { const [isPeerHost, setIsPeerHost] = React.useState(false); const { initialize, me } = useHuddle01(); - const { isRoomJoined } = useRoom(); + const { isRoomJoined, error } = useRoom(); const { peers } = usePeers(); const { joinLobby, leaveLobby, isLoading, isLobbyJoined } = useLobby(); const [accessDenied, setAccessDenied] = React.useState(false); @@ -48,7 +48,7 @@ const MeetLobby = ({ params }) => { const { fetchVideoStream, stopVideoStream, - error, + // error, } = useVideo(); const { joinRoom } = useRoom(); // const { setDisplayName } = useAppUtils(); @@ -87,6 +87,8 @@ const MeetLobby = ({ params }) => { } } + console.log(error) + const checkLobbyConditions = async () => { var { address } = await getWalletDetails(); setMyEthAddress(address); @@ -149,15 +151,19 @@ const MeetLobby = ({ params }) => { if (isRoomJoined) { push(`/meeting/room/${params.slug}`); } + console.log(isRoomJoined) + console.log("abcd") }, [isRoomJoined]); - + console.log(isRoomJoined) const handleMeetStart = () => { console.log("is lobby joined", isLobbyJoined) - if (!isLobbyJoined) return; + // if (!isLobbyJoined) return; setMyPeerId(me.meId); + console.log("joining room") joinRoom(); + console.log("joining room done") } if (isLoading) return (
) @@ -167,6 +173,7 @@ const MeetLobby = ({ params }) => { {/* {isLobbyJoined} {JSON.stringify(peers)} */} + {isRoomJoined}

READY TO JOIN?

@@ -281,7 +288,7 @@ const MeetLobby = ({ params }) => { }} > - {`JOIN MEET`} + {`JOIN MEET ${joinRoom.isCallable}`}
diff --git a/frontend/app/meeting/room/[slug]/components/ChatBox.jsx b/frontend/app/meeting/room/[slug]/components/ChatBox.jsx index f1c4a9a9..a8a11d6d 100644 --- a/frontend/app/meeting/room/[slug]/components/ChatBox.jsx +++ b/frontend/app/meeting/room/[slug]/components/ChatBox.jsx @@ -122,6 +122,8 @@ const ChatBox = ({ chatBox, peers }) => { } }; + console.log(roomMessages) + return (
{chatBox && ( @@ -190,7 +192,7 @@ const ChatBox = ({ chatBox, peers }) => { ); })}
- + {/* Individual messages */}
{ { roomMessages.filter( (message) => - message.sender?.meId == talkTo || message.receiver == talkTo + message.sender?.meId == talkTo || message.receiver == talkTo || message.receivers?.includes(talkTo) ).length > 0 ? roomMessages .filter( @@ -358,13 +360,15 @@ const ChatBox = ({ chatBox, peers }) => { message: groupMessage, kind: "private", receiver: peerId, + receivers: peerIdsToSend, timeStamp: formatTime(new Date().getTime()), }); - addRoomMessage([peerId], { + addRoomMessage({ sender: me, message: groupMessage, kind: "private", receiver: peerId, + receivers: peerIdsToSend, timeStamp: formatTime(new Date().getTime()), }); console.log(