diff --git a/src/stores/useDataStore/index.ts b/src/stores/useDataStore/index.ts index 705f63cc1..72dd1805e 100644 --- a/src/stores/useDataStore/index.ts +++ b/src/stores/useDataStore/index.ts @@ -323,13 +323,17 @@ export const useDataStore = create()( console.log(updatedNode) }, addNewNode: (data) => { - const { dataInitial: existingData } = get() + const { dataInitial: existingData, filters } = get() if (!data?.nodes) { return } - const uniqueIncomingNodes = deduplicateByRefId(data.nodes || []) + const nodesFilteredByFilters = filters.node_type.length + ? data.nodes.filter((node) => filters.node_type.some((t) => t === node.node_type)) + : data.nodes + + const uniqueIncomingNodes = deduplicateByRefId(nodesFilteredByFilters || []) const uniqueIncomingEdges = deduplicateByRefId(data.edges || []) // Step 2: Existing nodes and links from the current state