From 129088d61ee7c475281669fce20311731ed1e12d Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Sun, 28 May 2023 10:49:23 -0300 Subject: [PATCH] hotfix for file nodes and save on localStorage --- .../src/CustomNodes/GenericNode/index.tsx | 1 + src/frontend/src/contexts/tabsContext.tsx | 34 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 059fdfb81..8005a8a30 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -86,6 +86,7 @@ export default function GenericNode({ deleteNode(data.id); return; } + console.log(data) return (
{ - if(flow.data && flow.data?.nodes) flow.data?.nodes.forEach((node) => { - console.log(node.data.type) - Object.keys(node.data.node.template).forEach((key) => { - console.log(node.data.node.template[key].type) - if(node.data.node.template[key].type==="file"){ - console.log(node.data.node.template[key]) - node.data.node.template[key].content = ""; - } - }) - }) - }) - window.localStorage.setItem( + if (Saveflows.length !== 0){ + Saveflows.forEach((flow) => { + if(flow.data && flow.data?.nodes) flow.data?.nodes.forEach((node) => { + console.log(node.data.type) + //looking for file fields to prevent saving the content and breaking the flow for exceeding the the data limite for local storage + Object.keys(node.data.node.template).forEach((key) => { + console.log(node.data.node.template[key].type) + if(node.data.node.template[key].type==="file"){ + console.log(node.data.node.template[key]) + node.data.node.template[key].content = null; + node.data.node.template[key].value = ""; + + } + }) + }) + }) + window.localStorage.setItem( "tabsData", JSON.stringify({ tabIndex, flows:Saveflows, id}) ); + } } useEffect(() => { //get tabs locally saved let cookie = window.localStorage.getItem("tabsData"); - console.log(cookie) if (cookie && Object.keys(templates).length > 0) { let cookieObject: LangFlowState = JSON.parse(cookie); cookieObject.flows.forEach((flow) => {