fix: await handleDropMedia and surface clip-add errors in Timeline
- handleDropMedia now returns the ActionResult from addClip/addClipToNewTrack - The tracksRef onDrop handler now awaits handleDropMedia so errors aren't silently lost - Replaces the swallowed catch block with a toast.error + console.error on failure - This makes clip-add failures visible instead of silently doing nothing
This commit is contained in:
parent
43a17ecd14
commit
76e6568ac6
1 changed files with 11 additions and 5 deletions
|
|
@ -486,13 +486,14 @@ export const Timeline: React.FC = () => {
|
||||||
return () => document.removeEventListener("mouseup", handleMouseUp);
|
return () => document.removeEventListener("mouseup", handleMouseUp);
|
||||||
}, [isBoxSelecting, handleBoxSelectionEnd]);
|
}, [isBoxSelecting, handleBoxSelectionEnd]);
|
||||||
|
|
||||||
|
// Returns the ActionResult so callers can check success and surface errors
|
||||||
const handleDropMedia = useCallback(
|
const handleDropMedia = useCallback(
|
||||||
async (trackId: string, mediaId: string, startTime: number) => {
|
async (trackId: string, mediaId: string, startTime: number) => {
|
||||||
const { addClip, addClipToNewTrack } = useProjectStore.getState();
|
const { addClip, addClipToNewTrack } = useProjectStore.getState();
|
||||||
if (trackId) {
|
if (trackId) {
|
||||||
await addClip(trackId, mediaId, startTime);
|
return addClip(trackId, mediaId, startTime);
|
||||||
} else {
|
} else {
|
||||||
await addClipToNewTrack(mediaId, startTime);
|
return addClipToNewTrack(mediaId, startTime);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
|
|
@ -1078,9 +1079,14 @@ export const Timeline: React.FC = () => {
|
||||||
if (!rawData) return;
|
if (!rawData) return;
|
||||||
const data = JSON.parse(rawData);
|
const data = JSON.parse(rawData);
|
||||||
if (!data?.mediaId) return;
|
if (!data?.mediaId) return;
|
||||||
handleDropMedia("", data.mediaId, snappedTime);
|
const result = await handleDropMedia("", data.mediaId, snappedTime);
|
||||||
} catch {
|
if (result && !result.success) {
|
||||||
// ignore
|
console.error("[Timeline] Failed to add clip to timeline:", result.error);
|
||||||
|
toast.error("Failed to add clip to timeline", result.error?.message ?? "");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[Timeline] Drop error:", err);
|
||||||
|
toast.error("Failed to add clip to timeline", String(err));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue