From e4b4cf19a26d40d57be7311a148bc353b6bf894d Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Fri, 28 Apr 2023 14:43:27 -0300 Subject: [PATCH] refactor(GenericNode): remove commented out code and add comments to code feat(GenericNode): add validation check for node changes by comparing length of nodes and edges array --- src/frontend/src/CustomNodes/GenericNode/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 93497c0fc..7ad4bd59f 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -32,7 +32,7 @@ export default function GenericNode({ const debouncedValidateNode = useDebouncedCallback(async () => { // Check if the validationStatus is "success" - if (validationStatus === "success") return; + // if (validationStatus === "success") return; try { const response = await fetch(`/validate/node/${data.id}`, { @@ -62,7 +62,11 @@ export default function GenericNode({ validateNode(); }, [ validateNode, - ...Object.values(data.node.template).flatMap((t) => Object.values(t)), + // Use the result of ...reactFlowInstance.toObject() + // to determine if the node has changed + // turn into an array of nodes and edges + // and compare the length of the array + ...Object.values(reactFlowInstance.toObject()), ]); useEffect(() => {