From 40c7fbb4f86130c83fbd9029e83c5e7550e3219d Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Sun, 6 Jul 2025 20:45:29 +0200 Subject: refactor: move to a typed-tracks system and add support for text --- apps/web/src/components/development-debug.tsx | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'apps/web/src/components/development-debug.tsx') diff --git a/apps/web/src/components/development-debug.tsx b/apps/web/src/components/development-debug.tsx index aef69999..f407e2e0 100644 --- a/apps/web/src/components/development-debug.tsx +++ b/apps/web/src/components/development-debug.tsx @@ -1,20 +1,17 @@ "use client"; -import { - useTimelineStore, - type TimelineClip, - type TimelineTrack, -} from "@/stores/timeline-store"; +import { useTimelineStore, type TimelineTrack } from "@/stores/timeline-store"; import { useMediaStore, type MediaItem } from "@/stores/media-store"; import { usePlaybackStore } from "@/stores/playback-store"; import { Button } from "@/components/ui/button"; import { useState } from "react"; +import type { TimelineElement } from "@/types/timeline"; // Only show in development const SHOW_DEBUG_INFO = process.env.NODE_ENV === "development"; -interface ActiveClip { - clip: TimelineClip; +interface ActiveElement { + element: TimelineElement; track: TimelineTrack; mediaItem: MediaItem | null; } @@ -28,31 +25,32 @@ export function DevelopmentDebug() { // Don't render anything in production if (!SHOW_DEBUG_INFO) return null; - // Get active clips at current time - const getActiveClips = (): ActiveClip[] => { - const activeClips: ActiveClip[] = []; + // Get active elements at current time + const getActiveElements = (): ActiveElement[] => { + const activeElements: ActiveElement[] = []; tracks.forEach((track) => { - track.clips.forEach((clip) => { - const clipStart = clip.startTime; - const clipEnd = - clip.startTime + (clip.duration - clip.trimStart - clip.trimEnd); + track.elements.forEach((element) => { + const elementStart = element.startTime; + const elementEnd = + element.startTime + + (element.duration - element.trimStart - element.trimEnd); - if (currentTime >= clipStart && currentTime < clipEnd) { + if (currentTime >= elementStart && currentTime < elementEnd) { const mediaItem = - clip.mediaId === "test" - ? null // Test clips don't have a real media item - : mediaItems.find((item) => item.id === clip.mediaId) || null; + element.type === "media" + ? mediaItems.find((item) => item.id === element.mediaId) || null + : null; // Text elements don't have media items - activeClips.push({ clip, track, mediaItem }); + activeElements.push({ element, track, mediaItem }); } }); }); - return activeClips; + return activeElements; }; - const activeClips = getActiveClips(); + const activeElements = getActiveElements(); return (
@@ -71,28 +69,30 @@ export function DevelopmentDebug() { {showDebug && (
- Active Clips ({activeClips.length}) + Active Elements ({activeElements.length})
- {activeClips.map((clipData, index) => ( + {activeElements.map((elementData, index) => (
{index + 1}
-
{clipData.clip.name}
+
{elementData.element.name}
- {clipData.mediaItem?.type || "test"} + {elementData.element.type === "media" + ? elementData.mediaItem?.type || "media" + : "text"}
))} - {activeClips.length === 0 && ( + {activeElements.length === 0 && (
- No active clips + No active elements
)}
-- cgit v1.3.1