fix(Upload): fix the wrong number for files being uploaded by skipping the submitted file if it's currently uploading

This commit is contained in:
Aminejv 2021-09-27 12:29:30 +01:00
parent 7aff27dff1
commit f0976aed8f

View File

@ -133,11 +133,12 @@ export function createUploadProvider({
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const fileKey = getFileKey(files[i]); const fileKey = getFileKey(files[i]);
const doesQueueIncludeFile = getUploadQueue().some( const doesQueueIncludeFile = getUploadQueue().some(
({ file }) => getFileKey(files[i]) === getFileKey(file) ({ file }) => getFileKey(file) === fileKey
); );
const isUploaded = fileKey in UploadStore.uploadedFiles; const isUploaded = fileKey in UploadStore.uploadedFiles;
const isUploading = UploadAbort.currentUploadingFile === fileKey;
// NOTE(amine): skip the file if already uploaded or is in queue // NOTE(amine): skip the file if already uploaded or is in queue
if (doesQueueIncludeFile || isUploaded) continue; if (doesQueueIncludeFile || isUploaded || isUploading) continue;
// NOTE(amine): if the added file has failed before, remove it from failedFilesCache // NOTE(amine): if the added file has failed before, remove it from failedFilesCache
if (fileKey in UploadStore.failedFilesCache) removeFileFromCache({ fileKey }); if (fileKey in UploadStore.failedFilesCache) removeFileFromCache({ fileKey });
@ -194,8 +195,9 @@ export function createUploadProvider({
({ file }) => getFileKey(linkAsFile) === getFileKey(file) ({ file }) => getFileKey(linkAsFile) === getFileKey(file)
); );
const isUploaded = fileKey in UploadStore.uploadedFiles; const isUploaded = fileKey in UploadStore.uploadedFiles;
const isUploading = UploadAbort.currentUploadingFile === fileKey;
// NOTE(amine): skip the file if already uploaded or is in queue // NOTE(amine): skip the file if already uploaded or is in queue
if (doesQueueIncludeFile || isUploaded) return; if (doesQueueIncludeFile || isUploaded || isUploading) return;
// NOTE(amine): if the added file has failed before, remove it from failedFilesCache // NOTE(amine): if the added file has failed before, remove it from failedFilesCache
if (fileKey in UploadStore.failedFilesCache) removeFileFromCache({ fileKey }); if (fileKey in UploadStore.failedFilesCache) removeFileFromCache({ fileKey });