Make history actions immutable

This commit is contained in:
Gasim Gasimzada 2020-01-09 12:51:36 +04:00
parent 642a11e380
commit ccb886730b
2 changed files with 21 additions and 10 deletions

View file

@ -214,10 +214,16 @@ export class App extends React.Component<{}, AppState> {
} else if (event[META_KEY] && event.code === "KeyZ") {
if (event.shiftKey) {
// Redo action
history.redoOnce(elements);
const data = history.redoOnce(elements);
if (data !== null) {
elements = data;
}
} else {
// undo action
history.undoOnce(elements);
const data = history.undoOnce(elements);
if (data !== null) {
elements = data;
}
}
this.forceUpdate();
event.preventDefault();