Files
main_frontend/src/shared/hooks/useTimelineTracks.ts
T
2026-02-27 23:34:17 +03:00

48 lines
1.1 KiB
TypeScript

import { useMemo } from "react"
import type { SelectedFile, UsedFile } from "@shared/context/WorkspaceContext"
export interface TimelineTracks {
showWaveform: boolean
showVideoFrames: boolean
showSubtitles: boolean
showSilence: boolean
showBRoll: boolean
}
const DEFAULT_TRACKS: TimelineTracks = {
showWaveform: false,
showVideoFrames: false,
showSubtitles: false,
showSilence: false,
showBRoll: false,
}
export function useTimelineTracks(
usedFiles: UsedFile[],
selectedFile: SelectedFile | null,
): TimelineTracks {
return useMemo(() => {
if (!selectedFile) return DEFAULT_TRACKS
const hasVideo = usedFiles.some((f) => f.iconType === "video")
const hasAudio = usedFiles.some(
(f) => f.iconType === "audio" || f.iconType === "video",
)
const hasTranscription = usedFiles.some(
(f) => f.artifactType === "TRANSCRIPTION_JSON",
)
const hasSilence = usedFiles.some(
(f) => f.artifactType === "SILENCE_REMOVED_VIDEO",
)
return {
showVideoFrames: hasVideo,
showWaveform: hasAudio,
showSubtitles: hasTranscription,
showSilence: hasSilence,
showBRoll: false,
}
}, [usedFiles, selectedFile])
}