clear pickedUploadType after use so that it doesn't get used for drag and drop upload which doesn't set a upload type

This commit is contained in:
Abhinav 2022-09-07 19:41:49 +05:30
parent 09864ffdbe
commit cbe17dbd42

View file

@ -225,8 +225,10 @@ export default function Uploader(props: Props) {
handleCollectionCreationAndUpload( handleCollectionCreationAndUpload(
importSuggestion, importSuggestion,
props.isFirstUpload props.isFirstUpload,
pickedUploadType.current
); );
pickedUploadType.current = null;
props.setLoading(false); props.setLoading(false);
} }
}, [webFiles, appContext.sharedFiles, electronFiles]); }, [webFiles, appContext.sharedFiles, electronFiles]);
@ -260,9 +262,10 @@ export default function Uploader(props: Props) {
localID: index, localID: index,
collectionID: collection.id, collectionID: collection.id,
})); }));
await waitInQueueAndUploadFiles(filesWithCollectionToUpload, [ waitInQueueAndUploadFiles(filesWithCollectionToUpload, [
collection, collection,
]); ]);
toUploadFiles.current = null;
} catch (e) { } catch (e) {
logError(e, 'Failed to upload files to existing collections'); logError(e, 'Failed to upload files to existing collections');
} }
@ -327,16 +330,14 @@ export default function Uploader(props: Props) {
}); });
throw e; throw e;
} }
await waitInQueueAndUploadFiles( waitInQueueAndUploadFiles(filesWithCollectionToUpload, collections);
filesWithCollectionToUpload, toUploadFiles.current = null;
collections
);
} catch (e) { } catch (e) {
logError(e, 'Failed to upload files to new collections'); logError(e, 'Failed to upload files to new collections');
} }
}; };
const waitInQueueAndUploadFiles = async ( const waitInQueueAndUploadFiles = (
filesWithCollectionToUploadIn: FileWithCollection[], filesWithCollectionToUploadIn: FileWithCollection[],
collections: Collection[] collections: Collection[]
) => { ) => {
@ -487,7 +488,8 @@ export default function Uploader(props: Props) {
const handleCollectionCreationAndUpload = ( const handleCollectionCreationAndUpload = (
importSuggestion: ImportSuggestion, importSuggestion: ImportSuggestion,
isFirstUpload: boolean isFirstUpload: boolean,
pickedUploadType: PICKED_UPLOAD_TYPE
) => { ) => {
if (isPendingDesktopUpload.current) { if (isPendingDesktopUpload.current) {
isPendingDesktopUpload.current = false; isPendingDesktopUpload.current = false;
@ -503,10 +505,7 @@ export default function Uploader(props: Props) {
} }
return; return;
} }
if ( if (isElectron() && pickedUploadType === PICKED_UPLOAD_TYPE.ZIPS) {
isElectron() &&
pickedUploadType.current === PICKED_UPLOAD_TYPE.ZIPS
) {
uploadFilesToNewCollections(UPLOAD_STRATEGY.COLLECTION_PER_FOLDER); uploadFilesToNewCollections(UPLOAD_STRATEGY.COLLECTION_PER_FOLDER);
return; return;
} }