@@ -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