From aec55fea832b8ff798050cd3a395d67719d2ce7a Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 19 May 2026 11:12:09 -0400 Subject: [PATCH] fix: await onDropMedia, fix stale closure deps, surface errors in TrackLane - Import ActionResult type from @openreel/core - onDropMedia prop type now returns Promise | void - handleDrop now awaits onDropMedia so failures are visible - Replace silent catch with console.error + toast.error on failure - Add allTracks, playheadPosition, snapSettings to handleDrop useCallback deps to fix stale closure bug (calculateSnap was using stale snap/track state) --- .../src/components/editor/timeline/TrackLane.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/editor/apps/web/src/components/editor/timeline/TrackLane.tsx b/services/editor/apps/web/src/components/editor/timeline/TrackLane.tsx index 22497a1..f30d729 100644 --- a/services/editor/apps/web/src/components/editor/timeline/TrackLane.tsx +++ b/services/editor/apps/web/src/components/editor/timeline/TrackLane.tsx @@ -5,6 +5,7 @@ import type { ShapeClip, SVGClip, StickerClip, + ActionResult, } from "@openreel/core"; import { ClipComponent } from "./ClipComponent"; import { TextClipComponent } from "./TextClipComponent"; @@ -28,7 +29,7 @@ interface TrackLaneProps { trackHeights: Map; timelineRef: React.RefObject; onSelectClip: (clipId: string, addToSelection: boolean) => void; - onDropMedia: (trackId: string, mediaId: string, startTime: number) => void; + onDropMedia: (trackId: string, mediaId: string, startTime: number) => Promise | void; onMoveClip: ( clipId: string, newStartTime: number, @@ -178,13 +179,18 @@ export const TrackLane: React.FC = ({ snapSettings, pixelsPerSecond, ); - onDropMedia(track.id, data.mediaId, snapResult.time); + const result = await onDropMedia(track.id, data.mediaId, snapResult.time); + if (result && !result.success) { + console.error("[TrackLane] Failed to add clip:", result.error); + toast.error("Failed to add clip", result.error?.message ?? ""); + } } - } catch { - // Silently ignore parse errors + } catch (err) { + console.error("[TrackLane] Drop error:", err); + toast.error("Failed to add clip", String(err)); } }, - [track.id, track.name, pixelsPerSecond, scrollX, onDropMedia], + [track.id, track.name, pixelsPerSecond, scrollX, onDropMedia, allTracks, playheadPosition, snapSettings], ); const handleResizeStart = useCallback(