@@ -282,16 +282,12 @@ export default {
282
282
},
283
283
284
284
mounted () {
285
- if (!this.autoRefresh) {
286
- // load the graph if the autorefresh is off
287
- this.refreshTimer = setInterval(this.refresh, 1000)
288
- this.refreshTimer = null
289
- }
290
285
// compile & instantiate graphviz wasm
291
286
/** @type {Promise<Graphviz>} */
292
287
this.graphviz = Graphviz.load()
293
288
// allow render to happen before we go configuring svgPanZoom
294
289
this.$nextTick(() => {
290
+ this.refresh()
295
291
this.updateTimer()
296
292
})
297
293
this.mountSVGPanZoom()
@@ -588,7 +584,10 @@ export default {
588
584
this.updating = true
589
585
590
586
// extract the graph (non reactive lists of nodes & edges)
591
- const nodes = this.getGraphNodes()
587
+ const nodes = await this.waitFor(() => {
588
+ const nodes = this.getGraphNodes()
589
+ return nodes.length ? nodes : false
590
+ })
592
591
const edges = this.getGraphEdges()
593
592
594
593
if (!nodes.length) {
@@ -622,11 +621,9 @@ export default {
622
621
// obtain the node dimensions to use in the layout
623
622
// NOTE: need to wait for the nodes to all be rendered before we can
624
623
// measure them
625
- let nodeDimensions
626
- await this.waitFor(() => {
624
+ const nodeDimensions = await this.waitFor(() => {
627
625
try {
628
- nodeDimensions = this.getNodeDimensions(nodes)
629
- return true // all nodes rendered
626
+ return this.getNodeDimensions(nodes) // all nodes rendered
630
627
} catch {
631
628
return false // one or more nodes awaiting render
632
629
}
@@ -664,9 +661,8 @@ export default {
664
661
// Will return when the callback returns something truthy.
665
662
// OR after the configured number of retries
666
663
for (let retry = 0; retry < retries; retry++) {
667
- if (callback()) {
668
- break
669
- }
664
+ const ret = callback()
665
+ if (ret) return ret
670
666
await new Promise(requestAnimationFrame)
671
667
await this.$nextTick()
672
668
}
0 commit comments