From 3fdc7da39cad50fde3c0f514dc5d0308bcd5b514 Mon Sep 17 00:00:00 2001 From: se030 Date: Wed, 31 May 2023 12:59:17 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=ED=9A=8C=EC=9D=98=EB=A1=9D=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=EC=97=90=20=EB=94=B0=EB=A5=B8=20URL=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=8F=20SELECT=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=9D=90=EB=A6=84=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Workspace/index.tsx | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/client/src/components/Workspace/index.tsx b/client/src/components/Workspace/index.tsx index 79344160..889d58b8 100644 --- a/client/src/components/Workspace/index.tsx +++ b/client/src/components/Workspace/index.tsx @@ -43,18 +43,6 @@ function Workspace() { setIsOnGoing(false); }, [id]); - useEffect(() => { - if (!momSocket) return; - - momSocket.on(MOM_EVENT.SELECT, ({ mom }: MomMessage.Selected) => { - setSelectedMom(mom); - }); - - return () => { - momSocket.off(MOM_EVENT.SELECT); - }; - }, [momSocket]); - useEffect(() => { if (!workspace) return; const { moms } = workspace; @@ -64,6 +52,7 @@ function Workspace() { } }, [workspace]); + // 선택된 회의록이 변경되면 서버에 emit SELECT useEffect(() => { const momId = getCurrentMom(pathname); if (!momSocket || !momId) return; @@ -72,6 +61,19 @@ function Workspace() { momSocket.emit(MOM_EVENT.SELECT, message); }, [pathname, momSocket]); + // on SELECT 통해 전달된 회의록 정보 selectedMom 상태에 반영 + useEffect(() => { + if (!momSocket) return; + + momSocket.on(MOM_EVENT.SELECT, ({ mom }: MomMessage.Selected) => { + setSelectedMom(mom); + }); + + return () => { + momSocket.off(MOM_EVENT.SELECT); + }; + }, [momSocket]); + useEffect(() => { if (!workspaceSocket) { return;