fix(nodes): getNode not returning proper node element

# What's changed?

* use `.find` instead of computed index
This commit is contained in:
bcakmakoglu
2022-06-03 21:21:53 +02:00
committed by Braks
parent 0373dae236
commit 0b21708b58
+2 -4
View File
@@ -3,10 +3,8 @@ import type { ComputedGetters, GraphEdge, GraphNode, State } from '~/types'
import { getNodesInside, isEdgeVisible } from '~/utils'
export default (state: State): ComputedGetters => {
const nodeIds = computed(() => state.nodes.map((n) => n.id))
const edgeIds = computed(() => state.edges.map((e) => e.id))
const getNode: ComputedGetters['getNode'] = computed(() => (id: string) => state.nodes[nodeIds.value.indexOf(id)])
const getEdge: ComputedGetters['getEdge'] = computed(() => (id: string) => state.edges[edgeIds.value.indexOf(id)])
const getNode: ComputedGetters['getNode'] = computed(() => (id: string) => state.nodes.find((node) => node.id === id))
const getEdge: ComputedGetters['getEdge'] = computed(() => (id: string) => state.edges.find((edge) => edge.id === id))
const getEdgeTypes = computed(() => {
const edgeTypes: Record<string, any> = {