diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:53:16 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:53:16 +0200 |
| commit | f8fb238b228881ef970739b7d884912058b41347 (patch) | |
| tree | e784085f29377242c5d1441ec46b397ada5170ef /apps/web/src/lib/commands/batch-command.ts | |
| parent | 0f5dca4f12d926ec0015116e85ec1129a6891f40 (diff) | |
| download | opencut-f8fb238b228881ef970739b7d884912058b41347.tar.gz | |
feat: centralize selection management
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; } } |
