| | |
| | | |
| | | const processNext = async () => { |
| | | while (queue.length > 0) { |
| | | const file = queue.shift(); |
| | | results.push(await this.processImage(file, maxWidth, maxHeight)); |
| | | const entry = queue.shift(); |
| | | const blob = await this.processImage(entry.file, maxWidth, maxHeight); |
| | | results.push({ uploadId: entry.uploadId, blob: blob }); |
| | | } |
| | | }; |
| | | |
| | |
| | | const otherEntries = uploadEntries.filter(e => !e.file.type.startsWith('image/')); |
| | | |
| | | // Process images in batches |
| | | const processedBlobs = await this.processImages( |
| | | imageEntries.map(e => e.file) |
| | | const processedImages = await this.processImages( |
| | | imageEntries.map(e => ({ file: e.file, uploadId: e.uploadId })) |
| | | ); |
| | | |
| | | // Update image uploads with processed blobs |
| | | for (let i = 0; i < imageEntries.length; i++) { |
| | | const { uploadId, upload } = imageEntries[i]; |
| | | upload.blob = processedBlobs[i]; |
| | | upload.fields.size = processedBlobs[i].size; |
| | | upload.status = 'queued'; |
| | | await this.setUpload(uploadId, upload); |
| | | processed++; |
| | | this.updateFieldProgress(fieldId, processed, totalFiles, 'Processing files...'); |
| | | for (const { uploadId, blob } of processedImages) { |
| | | const entry = imageEntries.find(e => e.uploadId === uploadId); |
| | | if (entry) { |
| | | entry.upload.blob = blob; |
| | | entry.upload.fields.size = blob.size; |
| | | entry.upload.status = 'queued'; |
| | | await this.setUpload(uploadId, entry.upload); |
| | | processed++; |
| | | this.updateFieldProgress(fieldId, processed, totalFiles, 'Processing files...'); |
| | | } |
| | | } |
| | | |
| | | // Handle non-image files (no processing needed) |