File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
rust/cubesql/cubesql/egraph-debug-template/src Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ async function layout(
6363 fitView ,
6464 navHistory ,
6565 showOnlySelected ,
66+ abortSignal ,
6667) {
6768 const defaultOptions = {
6869 'elk.algorithm' : 'layered' ,
@@ -143,6 +144,10 @@ async function layout(
143144 const elk = new ELK ( ) ;
144145 const { children } = await elk . layout ( graph ) ;
145146
147+ if ( abortSignal . aborted ) {
148+ return ;
149+ }
150+
146151 // By mutating the children in-place we saves ourselves from creating a
147152 // needless copy of the nodes array.
148153 const flatChildren = [ ] ;
@@ -153,9 +158,21 @@ async function layout(
153158
154159 setNodes ( flatChildren ) ;
155160 setEdges ( edges ) ;
161+
162+ if ( abortSignal . aborted ) {
163+ return ;
164+ }
156165 window . requestAnimationFrame ( ( ) => {
166+ if ( abortSignal . aborted ) {
167+ return ;
168+ }
169+
157170 if ( navHistory ?. length ) {
158171 setTimeout ( ( ) => {
172+ if ( abortSignal . aborted ) {
173+ return ;
174+ }
175+
159176 zoomTo ( fitView , navHistory ) ;
160177 } , 500 ) ;
161178 } else {
@@ -390,6 +407,8 @@ const LayoutFlow = () => {
390407 ) ;
391408
392409 useEffect ( ( ) => {
410+ const ac = new AbortController ( ) ;
411+
393412 layout (
394413 { } ,
395414 jsonClone ( preNodes ) ,
@@ -399,7 +418,10 @@ const LayoutFlow = () => {
399418 fitView ,
400419 navHistory ,
401420 showOnlySelected ,
421+ ac . signal ,
402422 ) ;
423+
424+ return ( ) => ac . abort ( ) ;
403425 } , [
404426 preNodes ,
405427 setNodes ,
You can’t perform that action at this time.
0 commit comments