From b656efba7dacd007ba00e5e68035c8501f7b3e58 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 4 Aug 2023 16:04:52 -0300 Subject: [PATCH] fix(tabsContext.tsx): add checkOldEdgesHandles function to ensure that only old edges with invalid handles are updated fix(reactflowUtils.ts): rename checkEdgesHandles function to checkOldEdgesHandles for clarity --- src/frontend/src/contexts/tabsContext.tsx | 7 +++++-- src/frontend/src/utils/reactflowUtils.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 90101025f..7efe4046b 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -27,6 +27,7 @@ import { import { TabsContextType, TabsState } from "../types/tabs"; import { addVersionToDuplicates, + checkOldEdgesHandles, scapeJSONParse, scapedJSONStringfy, updateEdgesHandleIds, @@ -154,8 +155,10 @@ export function TabsProvider({ children }: { children: ReactNode }) { function processFlowEdges(flow: FlowType) { if (!flow.data || !flow.data.edges) return; - const newEdges = updateEdgesHandleIds(flow.data); - flow.data.edges = newEdges; + if (checkOldEdgesHandles(flow.data.edges)) { + const newEdges = updateEdgesHandleIds(flow.data); + flow.data.edges = newEdges; + } flow.data.edges.forEach((edge) => { edge.className = ""; edge.style = { stroke: "#555" }; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 3e1484752..65720bc23 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -297,7 +297,7 @@ export function scapeJSONParse(json: string): any { } // this function receives an array of edges and return true if any of the handles are not a json string -export function checkEdgesHandles(edges: Edge[]): boolean { +export function checkOldEdgesHandles(edges: Edge[]): boolean { return edges.some( (edge) => !edge.sourceHandle ||