From 97cf2a152ce4828cb442d8be7da0a2639578d247 Mon Sep 17 00:00:00 2001 From: Jose Manuel Serrano Amaut <a20122128@pucp.pe> Date: Fri, 3 Mar 2023 00:09:21 -0500 Subject: [PATCH] [FEAT]: Add method for setting next uploadStatus given the new status --- src/files-ui/hooks/useDropzoneFileUpdater.ts | 40 +++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/files-ui/hooks/useDropzoneFileUpdater.ts b/src/files-ui/hooks/useDropzoneFileUpdater.ts index 1b5b133..b1bb4dd 100644 --- a/src/files-ui/hooks/useDropzoneFileUpdater.ts +++ b/src/files-ui/hooks/useDropzoneFileUpdater.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import { CustomValidateFileResponse, ExtFile, ExtFileInstance, ExtFileManager, FileValidatorProps, Localization, validateExtFileList } from "../core"; +import { CustomValidateFileResponse, ExtFile, ExtFileInstance, ExtFileManager, FileValidatorProps, Localization, setNextUploadStatus, validateExtFileList } from "../core"; /** * Effect for keeping track of changes @@ -51,36 +51,30 @@ const useDropzoneFileListUpdater = ( //if the current Ext file is not present anymore //add deleted flag const extFileIndex: number = value.findIndex((extFile: ExtFile) => extFile.id === extFileInstance.id) - if (extFileIndex === -1) { + if (extFileIndex === -1) { extFileInstance.extraData = { deleted: true } console.log("extFileUpdater not found", extFileInstance.id); } else { - extFileInstance.uploadStatus = value[extFileIndex].uploadStatus; - extFileInstance.uploadMessage = value[extFileIndex].uploadMessage; - if (value[extFileIndex].uploadStatus === undefined) { - console.log("extFileUpdater canceled", extFileInstance.id); + const currExtFileObj: ExtFile = value[extFileIndex]; - } else if (value[extFileIndex].uploadStatus === "aborted") { - console.log("extFileUpdater aborted", extFileInstance.id); - - } + setNextUploadStatus(extFileInstance, currExtFileObj); } }) - /* if (arrOfExtFiles.length !== value.length || value.length === 0) { - return; - } - for (let i = 0; i < arrOfExtFiles.length; i++) { - if ( - (value[i].uploadStatus === undefined) - && - (arrOfExtFiles[i].uploadStatus === "preparing") - ) { - console.log("useDropzoneFileListUpdater onCancel i", i); - arrOfExtFiles[i].uploadStatus = undefined; - } - } */ + /*if (arrOfExtFiles.length !== value.length || value.length === 0) { + return; + } + for (let i = 0; i < arrOfExtFiles.length; i++) { + if ( + (value[i].uploadStatus === undefined) + && + (arrOfExtFiles[i].uploadStatus === "preparing") + ) { + console.log("useDropzoneFileListUpdater onCancel i", i); + arrOfExtFiles[i].uploadStatus = undefined; + } + } */ } } // eslint-disable-next-line -- GitLab