diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-06-22 22:10:50 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-06-22 22:10:50 +0200 |
| commit | 7e3a80eb74af23a36cfff43aa61175e1630222e1 (patch) | |
| tree | 69ae37ec8a45a5d638d18f12afe661881f021afc /apps/web/src/stores | |
| parent | ce49c5ff5f75c32ecb74673ab88447f3574c61fa (diff) | |
| download | opencut-7e3a80eb74af23a36cfff43aa61175e1630222e1.tar.gz | |
improve lots of stuff around the editor
Diffstat (limited to 'apps/web/src/stores')
| -rw-r--r-- | apps/web/src/stores/timeline-store.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts index 243ed220..12129afa 100644 --- a/apps/web/src/stores/timeline-store.ts +++ b/apps/web/src/stores/timeline-store.ts @@ -33,9 +33,12 @@ interface TimelineStore { clipId: string,
newIndex: number
) => void;
+
+ // Computed values
+ getTotalDuration: () => number;
}
-export const useTimelineStore = create<TimelineStore>((set) => ({
+export const useTimelineStore = create<TimelineStore>((set, get) => ({
tracks: [],
addTrack: (type) => {
@@ -134,4 +137,17 @@ export const useTimelineStore = create<TimelineStore>((set) => ({ }),
}));
},
+
+ getTotalDuration: () => {
+ const { tracks } = get();
+ if (tracks.length === 0) return 0;
+
+ // Calculate the duration of each track (sum of all clips in that track)
+ const trackDurations = tracks.map((track) =>
+ track.clips.reduce((total, clip) => total + clip.duration, 0)
+ );
+
+ // Return the maximum track duration (longest track determines project duration)
+ return Math.max(...trackDurations, 0);
+ },
}));
|
