Fixed bug where it does not open and does not save correctly
This commit is contained in:
parent
2b10c6337f
commit
b431839bce
1 changed files with 15 additions and 5 deletions
|
|
@ -54,11 +54,21 @@ export function UndoRedoProvider({ children }) {
|
||||||
// push the current graph to the past state
|
// push the current graph to the past state
|
||||||
setPast((old) => {
|
setPast((old) => {
|
||||||
let newPast = cloneDeep(old);
|
let newPast = cloneDeep(old);
|
||||||
newPast[tabIndex] = old[tabIndex].slice(
|
let newState = {
|
||||||
old[tabIndex].length - defaultOptions.maxHistorySize + 1,
|
nodes: cloneDeep(getNodes()),
|
||||||
old[tabIndex].length
|
edges: cloneDeep(getEdges()),
|
||||||
);
|
};
|
||||||
newPast[tabIndex].push({ nodes: getNodes(), edges: 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;
|
return newPast;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue