From cfba25ccc6edf2412b5bf0023fb22c98b1f8c2f7 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 | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/client/src/components/Workspace/index.tsx b/client/src/components/Workspace/index.tsx index 79344160..b91c10f4 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; @@ -107,7 +109,7 @@ function Workspace() { {workspace && ( - + )}