diff --git a/src/components/Upload/UploadProgress/dialog.tsx b/src/components/Upload/UploadProgress/dialog.tsx index e802a83a0..72667ae1c 100644 --- a/src/components/Upload/UploadProgress/dialog.tsx +++ b/src/components/Upload/UploadProgress/dialog.tsx @@ -19,19 +19,18 @@ export function UploadProgressDialog() { const [hasUnUploadedFiles, setHasUnUploadedFiles] = useState(false); useEffect(() => { - if (!hasUnUploadedFiles) { - if ( - finishedUploads.get(UPLOAD_RESULT.ALREADY_UPLOADED)?.length > - 0 || - finishedUploads.get(UPLOAD_RESULT.BLOCKED)?.length > 0 || - finishedUploads.get(UPLOAD_RESULT.FAILED)?.length > 0 || - finishedUploads.get(UPLOAD_RESULT.LARGER_THAN_AVAILABLE_STORAGE) - ?.length > 0 || - finishedUploads.get(UPLOAD_RESULT.TOO_LARGE)?.length > 0 || - finishedUploads.get(UPLOAD_RESULT.UNSUPPORTED)?.length > 0 - ) { - setHasUnUploadedFiles(true); - } + if ( + finishedUploads.get(UPLOAD_RESULT.ALREADY_UPLOADED)?.length > 0 || + finishedUploads.get(UPLOAD_RESULT.BLOCKED)?.length > 0 || + finishedUploads.get(UPLOAD_RESULT.FAILED)?.length > 0 || + finishedUploads.get(UPLOAD_RESULT.LARGER_THAN_AVAILABLE_STORAGE) + ?.length > 0 || + finishedUploads.get(UPLOAD_RESULT.TOO_LARGE)?.length > 0 || + finishedUploads.get(UPLOAD_RESULT.UNSUPPORTED)?.length > 0 + ) { + setHasUnUploadedFiles(true); + } else { + setHasUnUploadedFiles(false); } }, [finishedUploads]); diff --git a/src/components/Upload/Uploader.tsx b/src/components/Upload/Uploader.tsx index f28840e1e..cb497a6f0 100644 --- a/src/components/Upload/Uploader.tsx +++ b/src/components/Upload/Uploader.tsx @@ -225,8 +225,10 @@ export default function Uploader(props: Props) { handleCollectionCreationAndUpload( importSuggestion, - props.isFirstUpload + props.isFirstUpload, + pickedUploadType.current ); + pickedUploadType.current = null; props.setLoading(false); } }, [webFiles, appContext.sharedFiles, electronFiles]); @@ -260,9 +262,10 @@ export default function Uploader(props: Props) { localID: index, collectionID: collection.id, })); - await waitInQueueAndUploadFiles(filesWithCollectionToUpload, [ + waitInQueueAndUploadFiles(filesWithCollectionToUpload, [ collection, ]); + toUploadFiles.current = null; } catch (e) { logError(e, 'Failed to upload files to existing collections'); } @@ -327,16 +330,14 @@ export default function Uploader(props: Props) { }); throw e; } - await waitInQueueAndUploadFiles( - filesWithCollectionToUpload, - collections - ); + waitInQueueAndUploadFiles(filesWithCollectionToUpload, collections); + toUploadFiles.current = null; } catch (e) { logError(e, 'Failed to upload files to new collections'); } }; - const waitInQueueAndUploadFiles = async ( + const waitInQueueAndUploadFiles = ( filesWithCollectionToUploadIn: FileWithCollection[], collections: Collection[] ) => { @@ -487,7 +488,8 @@ export default function Uploader(props: Props) { const handleCollectionCreationAndUpload = ( importSuggestion: ImportSuggestion, - isFirstUpload: boolean + isFirstUpload: boolean, + pickedUploadType: PICKED_UPLOAD_TYPE ) => { if (isPendingDesktopUpload.current) { isPendingDesktopUpload.current = false; @@ -503,10 +505,7 @@ export default function Uploader(props: Props) { } return; } - if ( - isElectron() && - pickedUploadType.current === PICKED_UPLOAD_TYPE.ZIPS - ) { + if (isElectron() && pickedUploadType === PICKED_UPLOAD_TYPE.ZIPS) { uploadFilesToNewCollections(UPLOAD_STRATEGY.COLLECTION_PER_FOLDER); return; }