Skip to content

Commit 2278d48

Browse files
committed
Feat: live mode ON : 노드 수정
1 parent 6fdbb63 commit 2278d48

4 files changed

Lines changed: 142 additions & 452 deletions

File tree

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/main/components/MindMapView.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const MindMapView = ({
5353
},
5454
onConnect: () => {
5555
client.subscribe(
56-
`/topic/conference/${projectId}`,
56+
`/topic/conference/${projectId}/history`,
5757
(message: any) => {
5858
const data: any = JSON.parse(message.body);
5959
console.log(data);
@@ -83,10 +83,51 @@ const MindMapView = ({
8383
]);
8484
}
8585

86+
if (data.event === "script_history") {
87+
if (Array.isArray(data.scriptList)) {
88+
setScripts(prev => [
89+
...prev,
90+
...data.scriptList.filter((x:any) => x && x.time && x.script),
91+
]);
92+
}
93+
}
94+
8695
if (data.event === "script") {
87-
console.log(data.scription)
8896
setScripts((prev) => [...prev, data.scription]);
8997
}
98+
}
99+
);
100+
101+
client.subscribe(
102+
`/topic/conference/${projectId}`,
103+
(message: any) => {
104+
const data: any = JSON.parse(message.body);
105+
console.log(data);
106+
107+
if (data.event === "create_node") {
108+
setInitialNodes(data.nodes);
109+
110+
const edges = data.nodes
111+
.filter((node: any) => node.parentId)
112+
.map((node: any, index: number) => ({
113+
id: `${index}`,
114+
source: node.parentId!,
115+
target: node.id,
116+
}));
117+
118+
setInitialEdges(edges);
119+
}
120+
121+
if (data.event === "summary") {
122+
setSummary((prev) => [
123+
...prev,
124+
{
125+
time: data.time,
126+
title: data.title,
127+
item: data.content,
128+
},
129+
]);
130+
}
90131

91132
if (data.event === "main_keywords") {
92133
setMainKeyword(

src/views/meeting/components/MindMapComponent.tsx

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ const MindMapComponent = ({
209209
body: JSON.stringify(data),
210210
});
211211

212-
console.log(JSON.stringify(data));
213-
214212
setScriptList([]);
215213
}
216214

@@ -221,6 +219,50 @@ const MindMapComponent = ({
221219
}
222220
}, [finalTranscript]);
223221

222+
const updateNode = () => {
223+
if (clientRef.current?.connected) {
224+
const liveNodes = buildNodesForLive(nodes, edges);
225+
const payload = {
226+
event: "live_on",
227+
projectId: conferenceData.projectId,
228+
nodes: JSON.stringify(liveNodes),
229+
};
230+
console.log(payload)
231+
clientRef.current.publish({
232+
destination: `/app/conference/${conferenceData.projectId}/live_on`,
233+
body: JSON.stringify(payload),
234+
});
235+
}
236+
}
237+
238+
// 컴포넌트 상단(함수 바깥 X) 어딘가에 추가
239+
type LiveNode = {
240+
id: string;
241+
type: string;
242+
data: { label: string };
243+
position: { x: number; y: number };
244+
parentId: string | null;
245+
};
246+
247+
const buildNodesForLive = (nodes: Node[], edges: Edge[]): LiveNode[] => {
248+
return nodes.map((n) => {
249+
// 들어오는 간선 하나를 parent로 간주 (없으면 루트)
250+
const incoming = edges.find((e) => e.target === n.id);
251+
const label =
252+
typeof (n.data as any)?.label === "string"
253+
? (n.data as any).label
254+
: String((n.data as any)?.label ?? "");
255+
256+
return {
257+
id: n.id,
258+
type: (n.type as string) ?? "default",
259+
data: { label },
260+
position: n.position, // ReactFlow 절대 좌표
261+
parentId: incoming?.source ?? null,
262+
};
263+
});
264+
};
265+
224266
const stopClick = async () => {
225267
try {
226268
setMode("end");
@@ -403,6 +445,9 @@ const MindMapComponent = ({
403445
onNodesDelete={onNodesDelete}
404446
onEdgesChange={onEdgesChange}
405447
onConnect={onConnect}
448+
nodesDraggable={mode !== "live"}
449+
nodesConnectable={mode !== "live"}
450+
elementsSelectable={mode !== "live"}
406451
fitView
407452
attributionPosition="top-right"
408453
></ReactFlow>
@@ -439,7 +484,12 @@ const MindMapComponent = ({
439484
type="checkbox"
440485
id="live"
441486
onClick={() => {
442-
setMode(mode === "live" ? "meeting" : "live");
487+
if (mode === "live") {
488+
setMode("meeting");
489+
} else {
490+
updateNode();
491+
setMode("live");
492+
}
443493
}}
444494
checked={mode === "live"}
445495
/>

0 commit comments

Comments
 (0)