diff options
| author | DevloperAmanSingh <amansinghneh211205@gmail.com> | 2025-06-25 21:41:10 +0530 |
|---|---|---|
| committer | DevloperAmanSingh <amansinghneh211205@gmail.com> | 2025-06-25 21:41:10 +0530 |
| commit | a511c57729eff4b388b0ba42ed4484483bca86a4 (patch) | |
| tree | 6a0959ff71312c93fbd2e258c8b6a043b809389b /apps | |
| parent | 76c3293ac4da175e902914b40eb71ece5efd2746 (diff) | |
| download | opencut-a511c57729eff4b388b0ba42ed4484483bca86a4.tar.gz | |
feat: enhance media processing with progress tracking
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/src/components/editor/media-panel.tsx | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/apps/web/src/components/editor/media-panel.tsx b/apps/web/src/components/editor/media-panel.tsx index f2b3f657..cdd67a86 100644 --- a/apps/web/src/components/editor/media-panel.tsx +++ b/apps/web/src/components/editor/media-panel.tsx @@ -17,27 +17,28 @@ export function MediaPanel() { const { mediaItems, addMediaItem, removeMediaItem } = useMediaStore(); const fileInputRef = useRef<HTMLInputElement>(null); const [isProcessing, setIsProcessing] = useState(false); + const [progress, setProgress] = useState(0); const [searchQuery, setSearchQuery] = useState(""); const [mediaFilter, setMediaFilter] = useState("all"); const processFiles = async (files: FileList | File[]) => { - // If no files, do nothing - if (!files?.length) return; - + if (!files || files.length === 0) return; setIsProcessing(true); + setProgress(0); try { // Process files (extract metadata, generate thumbnails, etc.) - const items = await processMediaFiles(files); + const processedItems = await processMediaFiles(files, (p) => + setProgress(p) + ); // Add each processed media item to the store - items.forEach((item) => { - addMediaItem(item); - }); + processedItems.forEach((item) => addMediaItem(item)); } catch (error) { - // Show error if processing fails - console.error("File processing failed:", error); + // Show error toast if processing fails + console.error("Error processing files:", error); toast.error("Failed to process files"); } finally { setIsProcessing(false); + setProgress(0); } }; @@ -241,15 +242,12 @@ export function MediaPanel() { {isProcessing ? ( <> <Upload className="h-4 w-4 animate-spin" /> - <span className="hidden md:inline ml-2">Processing...</span> + <span className="hidden md:inline ml-2">{progress}%</span> </> ) : ( <> <Plus className="h-4 w-4" /> - <span - className="hidden sm:inline ml-2" - aria-label="Add file" - > + <span className="hidden sm:inline ml-2" aria-label="Add file"> Add </span> </> |
