diff --git a/webapp/src/mutator.ts b/webapp/src/mutator.ts index 42d33da62..1b8b3ac9e 100644 --- a/webapp/src/mutator.ts +++ b/webapp/src/mutator.ts @@ -98,9 +98,11 @@ class Mutator { }, async () => { await beforeUndo?.() + const awaits = [] for (const block of blocks) { - await octoClient.deleteBlock(block.id) + awaits.push(octoClient.deleteBlock(block.id)) } + await Promise.all(awaits) }, description, this.undoGroupId, diff --git a/webapp/src/undomanager.ts b/webapp/src/undomanager.ts index 4d32b4894..2c1f58d10 100644 --- a/webapp/src/undomanager.ts +++ b/webapp/src/undomanager.ts @@ -128,11 +128,16 @@ class UndoManager { } const currentGroupId = command.groupId - do { + if (currentGroupId) { + do { + // eslint-disable-next-line no-await-in-loop + await this.execute(command, 'undo') + this.index -= 1 + command = this.commands[this.index] + } while (this.index >= 0 && currentGroupId === command.groupId) + } else { await this.execute(command, 'undo') - this.index -= 1 - command = this.commands[this.index] - } while (this.index >= 0 && currentGroupId && currentGroupId === command.groupId) + } if (this.onStateDidChange) { this.onStateDidChange() @@ -151,11 +156,16 @@ class UndoManager { } const currentGroupId = command.groupId - do { + if (currentGroupId) { + do { + // eslint-disable-next-line no-await-in-loop + await this.execute(command, 'redo') + this.index += 1 + command = this.commands[this.index + 1] + } while (this.index < this.commands.length - 1 && currentGroupId === command.groupId) + } else { await this.execute(command, 'redo') - this.index += 1 - command = this.commands[this.index + 1] - } while (this.index < this.commands.length - 1 && currentGroupId && currentGroupId === command.groupId) + } if (this.onStateDidChange) { this.onStateDidChange()