Skip to content

Commit

Permalink
refactor(getElements): use internal node position #603
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Nov 9, 2020
1 parent cf87acc commit 2db5a7b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/utils/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,18 @@ export const getNodesInside = (
};

export const getConnectedEdges = (nodes: Node[], edges: Edge[]): Edge[] => {
const nodeIds = nodes.map((n) => n.id);
const nodeIds = nodes.map((node) => node.id);

return edges.filter((e) => {
const sourceId = e.source.split('__')[0];
const targetId = e.target.split('__')[0];

return nodeIds.includes(sourceId) || nodeIds.includes(targetId);
});
return edges.filter((edge) => nodeIds.includes(edge.source) || nodeIds.includes(edge.target));
};

const parseElements = (nodes: Node[], edges: Edge[]): Elements => {
return [
...nodes.map((node) => {
const n = { ...node };

n.position = n.__rf.position;

delete n.__rf;
return n;
}),
Expand Down

0 comments on commit 2db5a7b

Please sign in to comment.