summaryrefslogtreecommitdiff
path: root/apps/web/src/types
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-07 19:06:36 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-07 19:06:36 +0200
commitbd0c7f22069d1a2e4b2a2d962becaf6b9e942414 (patch)
tree595eb9b49f655f7c30b008065c26612077474a82 /apps/web/src/types
parent11c0b89bd162fe0cb0633687fe5ad07977956ace (diff)
downloadopencut-bd0c7f22069d1a2e4b2a2d962becaf6b9e942414.tar.gz
refactor: store media relative to project, add storage for timeline data, and other things
Diffstat (limited to 'apps/web/src/types')
-rw-r--r--apps/web/src/types/project.ts15
-rw-r--r--apps/web/src/types/timeline.ts31
2 files changed, 39 insertions, 7 deletions
diff --git a/apps/web/src/types/project.ts b/apps/web/src/types/project.ts
index 8b1eff3f..e208be3a 100644
--- a/apps/web/src/types/project.ts
+++ b/apps/web/src/types/project.ts
@@ -1,7 +1,8 @@
-export interface TProject {
- id: string;
- name: string;
- thumbnail: string;
- createdAt: Date;
- updatedAt: Date;
-}
+export interface TProject {
+ id: string;
+ name: string;
+ thumbnail: string;
+ createdAt: Date;
+ updatedAt: Date;
+ mediaItems?: string[];
+}
diff --git a/apps/web/src/types/timeline.ts b/apps/web/src/types/timeline.ts
index 7079f091..a759de21 100644
--- a/apps/web/src/types/timeline.ts
+++ b/apps/web/src/types/timeline.ts
@@ -123,3 +123,34 @@ export function ensureMainTrack(tracks: TimelineTrack[]): TimelineTrack[] {
return tracks;
}
+
+// Timeline validation utilities
+export function canElementGoOnTrack(
+ elementType: "text" | "media",
+ trackType: TrackType
+): boolean {
+ if (elementType === "text") {
+ return trackType === "text";
+ } else if (elementType === "media") {
+ return trackType === "media" || trackType === "audio";
+ }
+ return false;
+}
+
+export function validateElementTrackCompatibility(
+ element: { type: "text" | "media" },
+ track: { type: TrackType }
+): { isValid: boolean; errorMessage?: string } {
+ const isValid = canElementGoOnTrack(element.type, track.type);
+
+ if (!isValid) {
+ const errorMessage =
+ element.type === "text"
+ ? "Text elements can only be placed on text tracks"
+ : "Media elements can only be placed on media or audio tracks";
+
+ return { isValid: false, errorMessage };
+ }
+
+ return { isValid: true };
+}