Web: Files: fixed upload action
This commit is contained in:
parent
3ce70f3218
commit
eb04ef8517
@ -277,6 +277,7 @@ class FilesActionStore {
|
||||
this.isMediaOpen();
|
||||
|
||||
try {
|
||||
this.filesStore.setOperationAction(true);
|
||||
await removeFiles(folderIds, fileIds, deleteAfter, immediately)
|
||||
.then(async (res) => {
|
||||
if (res[0]?.error) return Promise.reject(res[0].error);
|
||||
@ -330,6 +331,8 @@ class FilesActionStore {
|
||||
});
|
||||
setTimeout(() => clearSecondaryProgressData(), TIMEOUT);
|
||||
return toastr.error(err.message ? err.message : err);
|
||||
} finally {
|
||||
this.filesStore.setOperationAction(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -675,10 +678,13 @@ class FilesActionStore {
|
||||
label: translations?.deleteOperation,
|
||||
};
|
||||
|
||||
this.filesStore.setOperationAction(true);
|
||||
|
||||
if (isFile) {
|
||||
addActiveItems([itemId]);
|
||||
this.isMediaOpen();
|
||||
return deleteFile(itemId).then(async (res) => {
|
||||
return deleteFile(itemId)
|
||||
.then(async (res) => {
|
||||
if (res[0]?.error) return Promise.reject(res[0].error);
|
||||
const data = res[0] ? res[0] : null;
|
||||
await this.uploadDataStore.loopFilesOperations(data, pbData);
|
||||
@ -692,7 +698,8 @@ class FilesActionStore {
|
||||
toastr.success(translations.successRemoveFile)
|
||||
);
|
||||
}
|
||||
});
|
||||
})
|
||||
.finally(() => this.filesStore.setOperationAction(false));
|
||||
} else if (isRoom) {
|
||||
const items = Array.isArray(itemId) ? itemId : [itemId];
|
||||
addActiveItems(null, items);
|
||||
@ -715,7 +722,8 @@ class FilesActionStore {
|
||||
);
|
||||
} else {
|
||||
addActiveItems(null, [itemId]);
|
||||
return deleteFolder(itemId).then(async (res) => {
|
||||
return deleteFolder(itemId)
|
||||
.then(async (res) => {
|
||||
if (res[0]?.error) return Promise.reject(res[0].error);
|
||||
const data = res[0] ? res[0] : null;
|
||||
await this.uploadDataStore.loopFilesOperations(data, pbData);
|
||||
@ -731,7 +739,8 @@ class FilesActionStore {
|
||||
}
|
||||
|
||||
getIsEmptyTrash();
|
||||
});
|
||||
})
|
||||
.finally(() => this.filesStore.setOperationAction(false));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,6 +97,8 @@ class FilesStore {
|
||||
|
||||
isEmptyPage = false;
|
||||
|
||||
operationAction = false;
|
||||
|
||||
constructor(
|
||||
authStore,
|
||||
selectedFolderStore,
|
||||
@ -122,7 +124,7 @@ class FilesStore {
|
||||
socketHelper.on("s:modify-folder", async (opt) => {
|
||||
console.log("[WS] s:modify-folder", opt);
|
||||
|
||||
if (this.isLoading) return;
|
||||
if (this.isLoading || this.operationAction) return;
|
||||
|
||||
switch (opt?.cmd) {
|
||||
case "create":
|
||||
@ -229,6 +231,8 @@ class FilesStore {
|
||||
socketHelper.on("refresh-folder", (id) => {
|
||||
if (!id || this.isLoading) return;
|
||||
|
||||
console.log("TODO: refresh-folder");
|
||||
|
||||
//console.log(
|
||||
// `selected folder id ${this.selectedFolderStore.id} an changed folder id ${id}`
|
||||
//);
|
||||
@ -311,6 +315,10 @@ class FilesStore {
|
||||
});
|
||||
}
|
||||
|
||||
setOperationAction = (operationAction) => {
|
||||
this.operationAction = operationAction;
|
||||
};
|
||||
|
||||
updateSelectionStatus = (id, status, isEditing) => {
|
||||
const index = this.selection.findIndex((x) => x.id === id);
|
||||
|
||||
@ -1815,9 +1823,12 @@ class FilesStore {
|
||||
|
||||
showToast && showToast();
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
toastr.error(err);
|
||||
console.log("Need page reload");
|
||||
})
|
||||
.finally(() => {
|
||||
this.setOperationAction(false);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -431,7 +431,7 @@ class UploadDataStore {
|
||||
}
|
||||
});
|
||||
|
||||
// storeOriginalFiles && this.refreshFiles(file);
|
||||
storeOriginalFiles && this.refreshFiles(file);
|
||||
|
||||
if (fileInfo && fileInfo !== "password") {
|
||||
file.fileInfo = fileInfo;
|
||||
@ -653,6 +653,8 @@ class UploadDataStore {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.filesStore.setOperationAction(false);
|
||||
};
|
||||
|
||||
const isFiltered =
|
||||
@ -694,6 +696,7 @@ class UploadDataStore {
|
||||
file,
|
||||
path
|
||||
) => {
|
||||
this.filesStore.setOperationAction(true);
|
||||
const length = requestsDataArray.length;
|
||||
for (let index = 0; index < length; index++) {
|
||||
if (
|
||||
@ -769,10 +772,8 @@ class UploadDataStore {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
if (currentFile.action === "uploaded") {
|
||||
if (currentFile?.path?.length > 1) {
|
||||
this.refreshFiles(currentFile);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user