diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:54:06 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:54:06 +0200 |
| commit | cc150c7cfb859dfc38372210ec5bcc8bd196bbc4 (patch) | |
| tree | 6cc57c2c54b6fd941b97c663b919f934b1445dde /apps/web/src/lib/commands/batch-command.ts | |
| parent | 0488a6be455c225535414fd651c838c355a9d3bd (diff) | |
| parent | f8fb238b228881ef970739b7d884912058b41347 (diff) | |
| download | opencut-cc150c7cfb859dfc38372210ec5bcc8bd196bbc4.tar.gz | |
Merge branch 'refactor-selection-commands'
Diffstat (limited to 'apps/web/src/lib/commands/batch-command.ts')
| -rw-r--r-- | apps/web/src/lib/commands/batch-command.ts | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/web/src/lib/commands/batch-command.ts b/apps/web/src/lib/commands/batch-command.ts index 05b51d38..ea23411c 100644 --- a/apps/web/src/lib/commands/batch-command.ts +++ b/apps/web/src/lib/commands/batch-command.ts @@ -1,14 +1,21 @@ -import { Command } from "./base-command"; +import { Command, type CommandResult } from "./base-command"; export class BatchCommand extends Command { constructor(private commands: Command[]) { super(); } - execute(): void { + execute(): CommandResult | undefined { + let latestSelectionResult: CommandResult | undefined; + for (const command of this.commands) { - command.execute(); + const result = command.execute(); + if (result?.select !== undefined) { + latestSelectionResult = result; + } } + + return latestSelectionResult; } undo(): void { @@ -17,9 +24,16 @@ export class BatchCommand extends Command { } } - redo(): void { + redo(): CommandResult | undefined { + let latestSelectionResult: CommandResult | undefined; + for (const command of this.commands) { - command.execute(); + const result = command.redo(); + if (result?.select !== undefined) { + latestSelectionResult = result; + } } + + return latestSelectionResult; } } |
