perf(edges): too many loops in grouping watcher

This commit is contained in:
bcakmakoglu
2022-06-23 19:13:50 +02:00
committed by Braks
parent acc27a7867
commit f25f6bf9a1
@@ -63,14 +63,15 @@ const scope = effectScope()
onPaneReady(() => {
scope.run(() => {
const edgeAmount = computed(() => getEdges.length)
watch(
[$$(getSelectedNodes), $$(getEdges), $$(getNodes)],
[$$(getSelectedNodes), edgeAmount],
() => {
getEdges.reduce((acc, edge) => {
if (hooks[edge.id]) return acc
getEdges.forEach((edge) => {
if (hooks[edge.id]) return
hooks[edge.id] = useEdgeHooks(edge, emits)
return acc
}, hooks)
})
if (elevateEdgesOnSelect) {
nextTick(() => (groups = groupEdgesByZLevel(getEdges, getNode)))