mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
Move project entity shapes into the model layer so sibling domains no longer depend on timeline for core data types. Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { Command, type CommandResult } from "@/commands/base-command";
|
|
import { EditorCore } from "@/core";
|
|
import type { TScene } from "@/model";
|
|
import { updateSceneInArray } from "@/timeline/scenes";
|
|
|
|
export class RenameSceneCommand extends Command {
|
|
private savedScenes: TScene[] | null = null;
|
|
private previousName: string | null = null;
|
|
|
|
constructor(
|
|
private sceneId: string,
|
|
private newName: string,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
execute(): CommandResult | undefined {
|
|
const editor = EditorCore.getInstance();
|
|
const scenes = editor.scenes.getScenes();
|
|
|
|
this.savedScenes = [...scenes];
|
|
|
|
const scene = scenes.find((s) => s.id === this.sceneId);
|
|
if (!scene) {
|
|
console.error("Scene not found:", this.sceneId);
|
|
return;
|
|
}
|
|
|
|
this.previousName = scene.name;
|
|
|
|
const updatedScenes = updateSceneInArray({
|
|
scenes,
|
|
sceneId: this.sceneId,
|
|
updates: { name: this.newName, updatedAt: new Date() },
|
|
});
|
|
|
|
editor.scenes.setScenes({ scenes: updatedScenes });
|
|
}
|
|
|
|
undo(): void {
|
|
if (this.savedScenes && this.previousName !== null) {
|
|
const editor = EditorCore.getInstance();
|
|
editor.scenes.setScenes({ scenes: this.savedScenes });
|
|
}
|
|
}
|
|
}
|