@@ -107,19 +107,20 @@ async function updateCombinerToCollector(node: TLGraphNode) {
107107 // We now collect the links data, inputs and outputs, of the old node since these will be
108108 // lost when we remove it.
109109 const links : any [ ] = [ ] ;
110+ const graph = ( node . graph || app . graph ) ;
110111 for ( const [ index , output ] of node . outputs . entries ( ) ) {
111112 for ( const linkId of output . links || [ ] ) {
112- const link : LLink = ( app . graph as LGraph ) . links [ linkId ] ! ;
113+ const link : LLink = graph . links [ linkId ] ! ;
113114 if ( ! link ) continue ;
114- const targetNode = app . graph . getNodeById ( link . target_id ) ;
115+ const targetNode = graph . getNodeById ( link . target_id ) ;
115116 links . push ( { node : newNode , slot : index , targetNode, targetSlot : link . target_slot } ) ;
116117 }
117118 }
118119 for ( const [ index , input ] of node . inputs . entries ( ) ) {
119120 const linkId = input . link ;
120121 if ( linkId ) {
121- const link : LLink = ( app . graph as LGraph ) . links [ linkId ] ! ;
122- const originNode = app . graph . getNodeById ( link . origin_id ) ;
122+ const link : LLink = graph . links [ linkId ] ! ;
123+ const originNode = graph . getNodeById ( link . origin_id ) ;
123124 links . push ( {
124125 node : originNode ,
125126 slot : link . origin_slot ,
@@ -129,14 +130,14 @@ async function updateCombinerToCollector(node: TLGraphNode) {
129130 }
130131 }
131132 // Add the new node, remove the old node.
132- app . graph . add ( newNode ) ;
133+ graph . add ( newNode ) ;
133134 await wait ( ) ;
134135 // Now go through and connect the other nodes up as they were.
135136 for ( const link of links ) {
136137 link . node . connect ( link . slot , link . targetNode , link . targetSlot ) ;
137138 }
138139 await wait ( ) ;
139- app . graph . remove ( node ) ;
140+ graph . remove ( node ) ;
140141 }
141142}
142143
0 commit comments