Skip to content
Snippets Groups Projects
Commit 7a350f72 authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[FEAT]: Add method for setting next uploadStatus given the new status

parent 037f5dbe
No related branches found
No related tags found
No related merge requests found
...@@ -118,7 +118,8 @@ export { ...@@ -118,7 +118,8 @@ export {
addExtraData, addExtraData,
addHeaders, addHeaders,
sanitizeArrExtFile, sanitizeArrExtFile,
unexpectedErrorUploadResult unexpectedErrorUploadResult,
setNextUploadStatus
} from "./upload"; } from "./upload";
export { export {
......
...@@ -30,5 +30,6 @@ export { ...@@ -30,5 +30,6 @@ export {
completeUploadResult, completeUploadResult,
sanitizeArrExtFile, sanitizeArrExtFile,
unableToUploadResult, unableToUploadResult,
unexpectedErrorUploadResult unexpectedErrorUploadResult,
setNextUploadStatus
} from "./utils.upload"; } from "./utils.upload";
...@@ -116,21 +116,42 @@ export const sleepTransition = ( ...@@ -116,21 +116,42 @@ export const sleepTransition = (
} }
export const sanitizeArrExtFile = (arrExtFile: ExtFileInstance[]): ExtFile[] => { export const sanitizeArrExtFile = (arrExtFile: ExtFileInstance[]): ExtFile[] => {
/* console.log("sanitizeArrExtFile", arrExtFile.length, arrExtFile.filter((extFileInstance: ExtFileInstance) => extFileInstance.extraData?.deleted)
.map((extFileInstance: ExtFileInstance) => extFileInstance.toExtFile()).length);
*/
return arrExtFile.filter((extFileInstance: ExtFileInstance) => return arrExtFile.filter((extFileInstance: ExtFileInstance) =>
!extFileInstance.extraData?.deleted) !extFileInstance.extraData?.deleted)
.map((extFileInstance: ExtFileInstance) => { .map((extFileInstance: ExtFileInstance) => {
if (extFileInstance.uploadStatus === "aborted") { if (extFileInstance.uploadStatus === "aborted"
if(!extFileInstance.uploadMessage){ && !extFileInstance.uploadMessage) {
extFileInstance.uploadMessage="Upload aborted"; extFileInstance.uploadMessage = "Upload aborted by user";
} //extFileInstance.uploadStatus = "error";
extFileInstance.uploadStatus = "error";
} }
return extFileInstance.toExtFile() return extFileInstance.toExtFile()
}); });
}
/**
*
* @param extFileInstance
* @param extFileobj
*/
export const setNextUploadStatus = (
extFileInstance: ExtFileInstance,
extFileobj: ExtFile) => {
const prevStatus: UPLOADSTATUS | undefined = extFileInstance.uploadStatus;
const nextStstaus: UPLOADSTATUS | undefined = extFileobj.uploadStatus;
if (
prevStatus === "preparing" &&
["aborted", undefined].includes(nextStstaus)
) {
extFileInstance.uploadStatus = undefined;
} else if (
prevStatus === "uploading" &&
["aborted", undefined].includes(nextStstaus)
) {
extFileInstance.uploadStatus = "aborted";
}
extFileInstance.uploadMessage = extFileobj.uploadMessage;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment