flow saving itself in local browser history
This commit is contained in:
parent
9c87f93a54
commit
df00fbe32e
1 changed files with 29 additions and 31 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue