@@ -54,7 +54,7 @@ const initialNodes = data.combos
5454 . concat ( data . nodes . map ( toRegularNode ) ) ;
5555const initialEdges = data . edges . map ( toEdge ) ;
5656
57- function layout (
57+ async function layout (
5858 options ,
5959 nodes ,
6060 edges ,
@@ -126,28 +126,28 @@ function layout(
126126 }
127127
128128 const elk = new ELK ( ) ;
129- return elk . layout ( graph ) . then ( ( { children } ) => {
130- // By mutating the children in-place we saves ourselves from creating a
131- // needless copy of the nodes array.
132- const flattenChildren = [ ] ;
129+ const { children } = await elk . layout ( graph ) ;
133130
134- children . forEach ( ( node ) => {
135- elk2flow ( node , flattenChildren ) ;
136- } ) ;
131+ // By mutating the children in-place we saves ourselves from creating a
132+ // needless copy of the nodes array.
133+ const flattenChildren = [ ] ;
137134
138- setNodes ( flattenChildren ) ;
139- setEdges ( edges ) ;
140- window . requestAnimationFrame ( ( ) => {
141- if ( navHistory ?. length ) {
142- setTimeout ( ( ) => {
143- zoomTo ( fitView , navHistory ) ;
144- } , 500 ) ;
145- } else {
146- fitView ( ) ;
147- }
148- } ) ;
149- return flattenChildren ;
135+ children . forEach ( ( node ) => {
136+ elk2flow ( node , flattenChildren ) ;
137+ } ) ;
138+
139+ setNodes ( flattenChildren ) ;
140+ setEdges ( edges ) ;
141+ window . requestAnimationFrame ( ( ) => {
142+ if ( navHistory ?. length ) {
143+ setTimeout ( ( ) => {
144+ zoomTo ( fitView , navHistory ) ;
145+ } , 500 ) ;
146+ } else {
147+ fitView ( ) ;
148+ }
150149 } ) ;
150+ return flattenChildren ;
151151}
152152
153153const highlightColor = 'rgba(170,255,170,0.71)' ;
0 commit comments