From ea6247f4a14bc24f4f21d4272de51c20aa73e083 Mon Sep 17 00:00:00 2001 From: moklick Date: Thu, 26 May 2022 18:58:57 +0200 Subject: [PATCH] refactor(edges): compatible with immutable libs closes #2170 --- src/store/index.ts | 9 ++------- src/utils/changes.ts | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index 77b89068..e5c271a9 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -30,13 +30,8 @@ const createStore = () => set({ nodeInternals: createNodeInternals(nodes, get().nodeInternals) }); }, setEdges: (edges: Edge[]) => { - const { defaultEdgeOptions } = get(); - - if (defaultEdgeOptions) { - set({ edges: edges.map((e) => ({ ...defaultEdgeOptions, ...e })) }); - } else { - set({ edges }); - } + const { defaultEdgeOptions = {} } = get(); + set({ edges: edges.map((e) => ({ ...defaultEdgeOptions, ...e })) }); }, setDefaultNodesAndEdges: (nodes?: Node[], edges?: Edge[]) => { const hasDefaultNodes = typeof nodes !== 'undefined'; diff --git a/src/utils/changes.ts b/src/utils/changes.ts index 5053857d..de0771c1 100644 --- a/src/utils/changes.ts +++ b/src/utils/changes.ts @@ -49,7 +49,6 @@ function applyChanges(changes: any[], elements: any[]): any[] { if (changes.some((c) => c.type === 'reset')) { return changes.filter((c) => c.type === 'reset').map((c) => c.item); } - console.log(changes); const initElements: any[] = changes.filter((c) => c.type === 'add').map((c) => c.item); return elements.reduce((res: any[], item: any) => {