Skip to content

Commit

Permalink
docs: 회의록 선택에 따른 URL 변경 및 SELECT 이벤트 흐름 주석 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
se030 committed May 31, 2023
1 parent 9bfe536 commit cfba25c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions client/src/components/Workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -64,6 +52,7 @@ function Workspace() {
}
}, [workspace]);

// 선택된 회의록이 변경되면 서버에 emit SELECT
useEffect(() => {
const momId = getCurrentMom(pathname);
if (!momSocket || !momId) return;
Expand All @@ -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;
Expand Down Expand Up @@ -107,7 +109,7 @@ function Workspace() {
<MeetingContext.Provider value={memoizedOnGoingValue}>
{workspace && (
<SelectedMomContext.Provider value={{ selectedMom, setSelectedMom }}>
<Sidebar workspace={workspace} />
<Sidebar />
<Mom />
</SelectedMomContext.Provider>
)}
Expand Down

0 comments on commit cfba25c

Please sign in to comment.