Skip to content

Commit

Permalink
#451 refactor doUndo, doRedo using async / await
Browse files Browse the repository at this point in the history
  • Loading branch information
klues committed Nov 28, 2024
1 parent c8faee0 commit f6a2c0f
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/js/service/data/undoService.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ function UndoService() {
* undoes to last state
* @return {*} last gridData which was used for undo
*/
thiz.doUndo = function () {
thiz.doUndo = async function () {
if (this.canUndo()) {
var undoData = _undoGridDataStack.pop();
let undoData = _undoGridDataStack.pop();
stateService.setCurrentGrid(undoData);
dataService.getGrid(undoData.id).then((savedGrid) => {
_redoGridDataStack.push(JSON.parse(JSON.stringify(savedGrid)));
dataService.saveGrid(undoData);
});
let savedGrid = await dataService.getGrid(undoData.id);
_redoGridDataStack.push(JSON.parse(JSON.stringify(savedGrid)));
await dataService.saveGrid(undoData);
return undoData;
}
};
Expand All @@ -65,14 +64,13 @@ function UndoService() {
* redoes to last state
* @return {*} last gridData which was used for redo
*/
thiz.doRedo = function () {
thiz.doRedo = async function () {
if (this.canRedo()) {
var redoData = _redoGridDataStack.pop();
let redoData = _redoGridDataStack.pop();
stateService.setCurrentGrid(redoData);
dataService.getGrid(redoData.id).then((savedGrid) => {
_undoGridDataStack.push(JSON.parse(JSON.stringify(savedGrid)));
dataService.saveGrid(redoData);
});
let savedGrid = await dataService.getGrid(redoData.id);
_undoGridDataStack.push(JSON.parse(JSON.stringify(savedGrid)));
await dataService.saveGrid(redoData);
return redoData;
}
};
Expand Down

0 comments on commit f6a2c0f

Please sign in to comment.