fix(flow): computed getter type

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent 13aae6aa3f
commit 981511c76f
6 changed files with 42 additions and 50 deletions
+3 -6
View File
@@ -1,10 +1,7 @@
import { ComputedRef } from 'vue'
import { defaultEdgeTypes, defaultNodeTypes } from './state'
import { State, GraphEdge, GraphNode, Getters } from '~/types'
import { State, GraphEdge, GraphNode, ComputedGetters } from '~/types'
import { getNodesInside, isEdgeVisible } from '~/utils'
export type ComputedGetters<N = any, E = N> = { [key in keyof Getters<N, E>]: ComputedRef<Getters<N, E>[key]> }
export default (state: State): ComputedGetters => {
const getEdgeTypes = computed(() => {
const edgeTypes: Record<string, any> = {
@@ -27,7 +24,7 @@ export default (state: State): ComputedGetters => {
})
const getNodes = computed<GraphNode[]>(() => {
if (state.paneReady && state.dimensions.width && state.dimensions.height) {
if (state.paneReady) {
const nodes = state.nodes.filter((n) => !n.hidden)
return state.onlyRenderVisibleElements
? nodes &&
@@ -48,7 +45,7 @@ export default (state: State): ComputedGetters => {
})
const getEdges = computed<GraphEdge[]>(() => {
if (state.paneReady && state.dimensions.width && state.dimensions.height) {
if (state.paneReady) {
if (!state.onlyRenderVisibleElements)
return state.edges.filter(
(e) => !e.hidden && e.targetNode && !e.targetNode.hidden && e.sourceNode && !e.sourceNode.hidden,