Fixed bug where it does not open and does not save correctly

This commit is contained in:
Lucas Oliveira 2023-10-19 17:20:21 -03:00
commit b431839bce

View file

@ -54,11 +54,21 @@ export function UndoRedoProvider({ children }) {
// push the current graph to the past state
setPast((old) => {
let newPast = cloneDeep(old);
newPast[tabIndex] = old[tabIndex].slice(
old[tabIndex].length - defaultOptions.maxHistorySize + 1,
old[tabIndex].length
);
newPast[tabIndex].push({ nodes: getNodes(), edges: getEdges() });
let newState = {
nodes: cloneDeep(getNodes()),
edges: cloneDeep(getEdges()),
};
if (
old[tabIndex] &&
JSON.stringify(old[tabIndex][old[tabIndex].length - 1]) !==
JSON.stringify(newState)
) {
newPast[tabIndex] = old[tabIndex].slice(
old[tabIndex].length - defaultOptions.maxHistorySize + 1,
old[tabIndex].length
);
newPast[tabIndex].push(newState);
}
return newPast;
});