Skip to content

Commit

Permalink
Merge pull request #2366 from stakwork/feature/realtime-filters-support
Browse files Browse the repository at this point in the history
feat: added filtering for new coming nodes by node type
  • Loading branch information
Rassl authored Oct 21, 2024
2 parents f083a8c + 65a4388 commit eb95b44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,17 @@ export const useDataStore = create<DataStore>()(
console.log(updatedNode)

Check warning on line 323 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
},
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
Expand Down

0 comments on commit eb95b44

Please sign in to comment.