| | |
| | | ], |
| | | }); |
| | | |
| | | window.jvbUploadBlobs = this.uploadStore; |
| | | |
| | | // Subscribe to store events |
| | | this.fieldStore.subscribe(this.handleFieldStoreEvent.bind(this)); |
| | | this.uploadStore.subscribe(this.handleUploadStoreEvent.bind(this)); |
| | |
| | | // Core data structures |
| | | this.fields = new Map(); |
| | | this.uploads = new Map(); |
| | | this.uploadBlobs = new Map(); |
| | | this.groups = new Map(); |
| | | this.selected = new Map(); |
| | | this.selectionHandlers = new Map(); |
| | |
| | | formData.append('posts', JSON.stringify(posts)); |
| | | formData.append('upload_ids', JSON.stringify(uploadMap)); |
| | | |
| | | for (const [key, value] of formData.entries()) { |
| | | console.log(key, value); |
| | | } |
| | | const operation = { |
| | | endpoint: 'uploads/groups', |
| | | method: 'POST', |
| | |
| | | } |
| | | } |
| | | async saveUpload(upload) { |
| | | // Handle blob data separately |
| | | if (upload.file instanceof File || upload.file instanceof Blob) { |
| | | await this.uploadStore.saveBlob(upload.id, upload.file); |
| | | // Don't store the file in the main store |
| | | const { file, originalFile, ...cleanUpload } = upload; |
| | | // Use the processed file if available, otherwise original |
| | | const fileToStore = upload.processedFile || upload.originalFile || upload.file; |
| | | |
| | | if (fileToStore instanceof File || fileToStore instanceof Blob) { |
| | | await this.uploadStore.saveBlob(upload.id, fileToStore); |
| | | |
| | | // Don't store file objects in main store |
| | | const { file, originalFile, processedFile, ...cleanUpload } = upload; |
| | | await this.uploadStore.save(cleanUpload); |
| | | } else { |
| | | await this.uploadStore.save(upload); |