Hotfix: saving flow flow in the browser local storage (#315)

hotfix for keeping the flow when the browser refresh, saving flow
locally.
This commit is contained in:
anovazzi1 2023-05-17 10:40:08 -03:00 • committed by GitHub
commit 04bd055c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 32 deletions

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "langflow" name = "langflow"
version = "0.0.73" version = "0.0.74"
description = "A Python package with a built-in web application" description = "A Python package with a built-in web application"
authors = ["Logspace <contact@logspace.ai>"] authors = ["Logspace <contact@logspace.ai>"]
maintainers = [ maintainers = [

View file

@ -47,44 +47,42 @@ export function TabsProvider({ children }: { children: ReactNode }) {
return newNodeId.current; return newNodeId.current;
} }
function save() { function save() {
//disabled until flows can be saved on local storage again without bugs if (flows.length !== 0)
// if (flows.length !== 0) window.localStorage.setItem(
// window.localStorage.setItem( "tabsData",
// "tabsData", JSON.stringify({ tabIndex, flows, id, nodeId: newNodeId.current })
// JSON.stringify({ tabIndex, flows, id, nodeId: newNodeId.current }) );
// );
} }
useEffect(() => { useEffect(() => {
//disabled until flows can be saved on local storage again without bugs
//save tabs locally //save tabs locally
// save(); save();
}, [flows, id, tabIndex, newNodeId]); }, [flows, id, tabIndex, newNodeId]);
// useEffect(() => { useEffect(() => {
// //get tabs locally saved //get tabs locally saved
// let cookie = window.localStorage.getItem("tabsData"); let cookie = window.localStorage.getItem("tabsData");
// if (cookie && Object.keys(templates).length > 0) { if (cookie && Object.keys(templates).length > 0) {
// let cookieObject: LangFlowState = JSON.parse(cookie); let cookieObject: LangFlowState = JSON.parse(cookie);
// cookieObject.flows.forEach((flow) => { cookieObject.flows.forEach((flow) => {
// flow.data.nodes.forEach((node) => { flow.data.nodes.forEach((node) => {
// if (Object.keys(templates[node.data.type]["template"]).length > 0) { if (Object.keys(templates[node.data.type]["template"]).length > 0) {
// node.data.node.template = updateTemplate( node.data.node.template = updateTemplate(
// templates[node.data.type][ templates[node.data.type][
// "template" "template"
// ] as unknown as APITemplateType, ] as unknown as APITemplateType,
// node.data.node.template as APITemplateType node.data.node.template as APITemplateType
// ); );
// } }
// }); });
// }); });
// setTabIndex(cookieObject.tabIndex); setTabIndex(cookieObject.tabIndex);
// setFlows(cookieObject.flows); setFlows(cookieObject.flows);
// setId(cookieObject.id); setId(cookieObject.id);
// newNodeId.current = cookieObject.nodeId; newNodeId.current = cookieObject.nodeId;
// } }
// }, [templates]); }, [templates]);
function hardReset() { function hardReset() {
newNodeId.current = 0; newNodeId.current = 0;