From df00fbe32ed1a8a4cf32c10737b54b2e6d114762 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 17 May 2023 10:30:36 -0300 Subject: [PATCH 1/2] flow saving itself in local browser history --- src/frontend/src/contexts/tabsContext.tsx | 60 +++++++++++------------ 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 51f754902..ad5811f58 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -47,44 +47,42 @@ export function TabsProvider({ children }: { children: ReactNode }) { return newNodeId.current; } function save() { - //disabled until flows can be saved on local storage again without bugs - // if (flows.length !== 0) - // window.localStorage.setItem( - // "tabsData", - // JSON.stringify({ tabIndex, flows, id, nodeId: newNodeId.current }) - // ); + if (flows.length !== 0) + window.localStorage.setItem( + "tabsData", + JSON.stringify({ tabIndex, flows, id, nodeId: newNodeId.current }) + ); } useEffect(() => { - //disabled until flows can be saved on local storage again without bugs //save tabs locally - // save(); + save(); }, [flows, id, tabIndex, newNodeId]); - // useEffect(() => { - // //get tabs locally saved - // let cookie = window.localStorage.getItem("tabsData"); - // if (cookie && Object.keys(templates).length > 0) { - // let cookieObject: LangFlowState = JSON.parse(cookie); - // cookieObject.flows.forEach((flow) => { - // flow.data.nodes.forEach((node) => { - // if (Object.keys(templates[node.data.type]["template"]).length > 0) { - // node.data.node.template = updateTemplate( - // templates[node.data.type][ - // "template" - // ] as unknown as APITemplateType, + useEffect(() => { + //get tabs locally saved + let cookie = window.localStorage.getItem("tabsData"); + if (cookie && Object.keys(templates).length > 0) { + let cookieObject: LangFlowState = JSON.parse(cookie); + cookieObject.flows.forEach((flow) => { + flow.data.nodes.forEach((node) => { + if (Object.keys(templates[node.data.type]["template"]).length > 0) { + node.data.node.template = updateTemplate( + templates[node.data.type][ + "template" + ] as unknown as APITemplateType, - // node.data.node.template as APITemplateType - // ); - // } - // }); - // }); - // setTabIndex(cookieObject.tabIndex); - // setFlows(cookieObject.flows); - // setId(cookieObject.id); - // newNodeId.current = cookieObject.nodeId; - // } - // }, [templates]); + node.data.node.template as APITemplateType + ); + } + }); + }); + setTabIndex(cookieObject.tabIndex); + setFlows(cookieObject.flows); + setId(cookieObject.id); + newNodeId.current = cookieObject.nodeId; + } + }, [templates]); function hardReset() { newNodeId.current = 0; From f5a12b73126f04508033bf4fda08883fcd051b67 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 17 May 2023 10:34:37 -0300 Subject: [PATCH 2/2] update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 12ba07ebb..d9a6dffcd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.0.73" +version = "0.0.74" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [