summaryrefslogtreecommitdiff
path: root/apps/web/src/stores/timeline-store.ts
diff options
context:
space:
mode:
authorSompalkar <palkarsom1@gmail.com>2025-06-23 14:43:12 +0530
committerSompalkar <palkarsom1@gmail.com>2025-06-23 14:43:12 +0530
commit9abb502919135782cc51e82fa8a7154a7fc95a80 (patch)
tree3c52e40fa209acc8807652c063c9b1c2ade50a6c /apps/web/src/stores/timeline-store.ts
parent56efb55a0fbcd22fefd6d8c5cf4300166b7f168a (diff)
downloadopencut-9abb502919135782cc51e82fa8a7154a7fc95a80.tar.gz
fix: delete only selected clip from timeline
Diffstat (limited to 'apps/web/src/stores/timeline-store.ts')
-rw-r--r--apps/web/src/stores/timeline-store.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts
index 4b56e6bd..c569ae11 100644
--- a/apps/web/src/stores/timeline-store.ts
+++ b/apps/web/src/stores/timeline-store.ts
@@ -15,6 +15,7 @@ export interface TimelineTrack {
name: string;
type: "video" | "audio" | "effects";
clips: TimelineClip[];
+ muted?: boolean;
}
interface TimelineStore {
@@ -41,6 +42,7 @@ interface TimelineStore {
clipId: string,
startTime: number
) => void;
+ toggleTrackMute: (trackId: string) => void;
// Computed values
getTotalDuration: () => number;
@@ -55,6 +57,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({
name: `${type.charAt(0).toUpperCase() + type.slice(1)} Track`,
type,
clips: [],
+ muted: false,
};
set((state) => ({
tracks: [...state.tracks, newTrack],
@@ -125,8 +128,6 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({
});
},
-
-
updateClipTrim: (trackId, clipId, trimStart, trimEnd) => {
set((state) => ({
tracks: state.tracks.map((track) =>
@@ -134,9 +135,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({
? {
...track,
clips: track.clips.map((clip) =>
- clip.id === clipId
- ? { ...clip, trimStart, trimEnd }
- : clip
+ clip.id === clipId ? { ...clip, trimStart, trimEnd } : clip
),
}
: track
@@ -151,9 +150,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({
? {
...track,
clips: track.clips.map((clip) =>
- clip.id === clipId
- ? { ...clip, startTime }
- : clip
+ clip.id === clipId ? { ...clip, startTime } : clip
),
}
: track
@@ -161,13 +158,22 @@ export const useTimelineStore = create<TimelineStore>((set, get) => ({
}));
},
+ toggleTrackMute: (trackId) => {
+ set((state) => ({
+ tracks: state.tracks.map((track) =>
+ track.id === trackId ? { ...track, muted: !track.muted } : track
+ ),
+ }));
+ },
+
getTotalDuration: () => {
const { tracks } = get();
if (tracks.length === 0) return 0;
const trackEndTimes = tracks.map((track) =>
track.clips.reduce((maxEnd, clip) => {
- const clipEnd = clip.startTime + clip.duration - clip.trimStart - clip.trimEnd;
+ const clipEnd =
+ clip.startTime + clip.duration - clip.trimStart - clip.trimEnd;
return Math.max(maxEnd, clipEnd);
}, 0)
);