mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 23:05:49 +00:00
Restore auto full-track clip on reopen
This commit is contained in:
@@ -1175,6 +1175,8 @@ export default function VideoEditor() {
|
||||
zoomRegions: ZoomRegion[];
|
||||
trimRegions: TrimRegion[];
|
||||
clipRegions: ClipRegion[];
|
||||
autoFullTrackClipId?: string | null;
|
||||
autoFullTrackClipEndMs?: number | null;
|
||||
speedRegions: SpeedRegion[];
|
||||
annotationRegions: AnnotationRegion[];
|
||||
audioRegions: AudioRegion[];
|
||||
@@ -1298,6 +1300,8 @@ export default function VideoEditor() {
|
||||
zoomRegions,
|
||||
trimRegions,
|
||||
clipRegions,
|
||||
autoFullTrackClipId: autoFullTrackClipIdRef.current,
|
||||
autoFullTrackClipEndMs: autoFullTrackClipEndMsRef.current,
|
||||
speedRegions,
|
||||
annotationRegions,
|
||||
audioRegions,
|
||||
@@ -1531,6 +1535,8 @@ export default function VideoEditor() {
|
||||
setTrimRegions(normalizedEditor.trimRegions);
|
||||
setClipRegions(normalizedEditor.clipRegions);
|
||||
clipInitializedRef.current = normalizedEditor.clipRegions.length > 0;
|
||||
autoFullTrackClipIdRef.current = normalizedEditor.autoFullTrackClipId ?? null;
|
||||
autoFullTrackClipEndMsRef.current = normalizedEditor.autoFullTrackClipEndMs ?? null;
|
||||
setSpeedRegions(normalizedEditor.speedRegions);
|
||||
setAnnotationRegions(normalizedEditor.annotationRegions);
|
||||
setAudioRegions(normalizedEditor.audioRegions);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { normalizeProjectEditor } from "./projectPersistence";
|
||||
|
||||
describe("normalizeProjectEditor", () => {
|
||||
it("preserves auto full-track clip metadata for reopened projects", () => {
|
||||
const normalized = normalizeProjectEditor({
|
||||
clipRegions: [{ id: "clip-1", startMs: 0, endMs: 5_000, speed: 1 }],
|
||||
autoFullTrackClipId: "clip-1",
|
||||
autoFullTrackClipEndMs: 5_000,
|
||||
});
|
||||
|
||||
expect(normalized.autoFullTrackClipId).toBe("clip-1");
|
||||
expect(normalized.autoFullTrackClipEndMs).toBe(5_000);
|
||||
});
|
||||
|
||||
it("drops invalid auto full-track clip metadata", () => {
|
||||
const normalized = normalizeProjectEditor({
|
||||
clipRegions: [{ id: "clip-1", startMs: 0, endMs: 5_000, speed: 1 }],
|
||||
autoFullTrackClipId: 123 as unknown as string,
|
||||
autoFullTrackClipEndMs: Number.NaN,
|
||||
});
|
||||
|
||||
expect(normalized.autoFullTrackClipId).toBeNull();
|
||||
expect(normalized.autoFullTrackClipEndMs).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -98,6 +98,8 @@ export interface ProjectEditorState {
|
||||
zoomRegions: ZoomRegion[];
|
||||
trimRegions: TrimRegion[];
|
||||
clipRegions: ClipRegion[];
|
||||
autoFullTrackClipId?: string | null;
|
||||
autoFullTrackClipEndMs?: number | null;
|
||||
speedRegions: SpeedRegion[];
|
||||
annotationRegions: AnnotationRegion[];
|
||||
audioRegions: AudioRegion[];
|
||||
@@ -411,6 +413,12 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro
|
||||
})
|
||||
: [];
|
||||
|
||||
const normalizedAutoFullTrackClipId =
|
||||
typeof editor.autoFullTrackClipId === "string" ? editor.autoFullTrackClipId : null;
|
||||
const normalizedAutoFullTrackClipEndMs = isFiniteNumber(editor.autoFullTrackClipEndMs)
|
||||
? Math.round(editor.autoFullTrackClipEndMs)
|
||||
: null;
|
||||
|
||||
const normalizedSpeedRegions: SpeedRegion[] = Array.isArray(editor.speedRegions)
|
||||
? editor.speedRegions
|
||||
.filter((region): region is SpeedRegion =>
|
||||
@@ -761,6 +769,8 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Pro
|
||||
zoomRegions: normalizedZoomRegions,
|
||||
trimRegions: normalizedTrimRegions,
|
||||
clipRegions: normalizedClipRegions,
|
||||
autoFullTrackClipId: normalizedAutoFullTrackClipId,
|
||||
autoFullTrackClipEndMs: normalizedAutoFullTrackClipEndMs,
|
||||
speedRegions: normalizedSpeedRegions,
|
||||
annotationRegions: normalizedAnnotationRegions,
|
||||
audioRegions: normalizedAudioRegions,
|
||||
|
||||
Reference in New Issue
Block a user