Browse Source

fix: use shared downloadMedia utility in output nodes

- OutputGalleryNode: replace hardcoded .png/.mp4 download with shared
  downloadMedia utility for correct MIME-based extensions
- OutputNode: wrap downloadMedia call in try/catch to prevent unhandled
  rejection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 3 months ago
parent
commit
c8dc3ec2f1
  1. 12
      src/components/nodes/OutputGalleryNode.tsx
  2. 6
      src/components/nodes/OutputNode.tsx

12
src/components/nodes/OutputGalleryNode.tsx

@ -8,6 +8,7 @@ import { useWorkflowStore } from "@/store/workflowStore";
import { OutputGalleryNodeData } from "@/types"; import { OutputGalleryNodeData } from "@/types";
import { useAdaptiveImageSrc } from "@/hooks/useAdaptiveImageSrc"; import { useAdaptiveImageSrc } from "@/hooks/useAdaptiveImageSrc";
import { defaultNodeDimensions } from "@/store/utils/nodeDefaults"; import { defaultNodeDimensions } from "@/store/utils/nodeDefaults";
import { downloadMedia as downloadMediaUtil } from "@/utils/downloadMedia";
type MediaItem = { type: "image" | "video"; src: string }; type MediaItem = { type: "image" | "video"; src: string };
@ -67,14 +68,9 @@ export function OutputGalleryNode({ id, data, selected }: NodeProps<OutputGaller
const item = displayMedia[lightboxIndex]; const item = displayMedia[lightboxIndex];
if (!item) return; if (!item) return;
const link = document.createElement("a"); downloadMediaUtil(item.src, item.type).catch((err) =>
link.href = item.src; console.error("Gallery download failed:", err)
link.download = item.type === "video" );
? `gallery-video-${lightboxIndex + 1}.mp4`
: `gallery-image-${lightboxIndex + 1}.png`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}, [lightboxIndex, displayMedia]); }, [lightboxIndex, displayMedia]);
const removeMedia = useCallback((index: number) => { const removeMedia = useCallback((index: number) => {

6
src/components/nodes/OutputNode.tsx

@ -76,7 +76,11 @@ export function OutputNode({ id, data, selected }: NodeProps<OutputNodeType>) {
const handleDownload = useCallback(async () => { const handleDownload = useCallback(async () => {
if (!contentSrc) return; if (!contentSrc) return;
const type: MediaType = isAudio ? "audio" : isVideo ? "video" : "image"; const type: MediaType = isAudio ? "audio" : isVideo ? "video" : "image";
await downloadMedia(contentSrc, type, nodeData.outputFilename ?? undefined); try {
await downloadMedia(contentSrc, type, nodeData.outputFilename ?? undefined);
} catch (err) {
console.error("Download failed:", err);
}
}, [contentSrc, isAudio, isVideo, nodeData.outputFilename]); }, [contentSrc, isAudio, isVideo, nodeData.outputFilename]);
return ( return (

Loading…
Cancel
Save