Web: Files: fixed cancel upload

This commit is contained in:
Nikita Gopienko 2023-03-02 13:54:05 +03:00
parent cbd8781a24
commit 74b19e27f2
2 changed files with 28 additions and 4 deletions

View File

@ -142,11 +142,11 @@ class FileRow extends Component {
onCancelCurrentUpload = (e) => {
//console.log("cancel upload ", e);
const { id, action, fileId } = e.currentTarget.dataset;
const { cancelCurrentUpload, cancelCurrentFileConversion } = this.props;
const { t, cancelCurrentUpload, cancelCurrentFileConversion } = this.props;
return action === "convert"
? cancelCurrentFileConversion(fileId)
: cancelCurrentUpload(id);
: cancelCurrentUpload(id, t);
};
onMediaClick = (id) => {

View File

@ -215,7 +215,31 @@ class UploadDataStore {
this.setUploadData(newUploadData);
};
cancelCurrentUpload = (id) => {
cancelCurrentUpload = (id, t) => {
if (this.isParallel) {
runInAction(() => {
const uploadedFilesHistory = this.uploadedFilesHistory.filter(
(el) => el.uniqueId !== id
);
const canceledFile = this.files.find((f) => f.uniqueId === id);
const newPercent = this.getFilesPercent(canceledFile.file.size);
canceledFile.cancel = true;
canceledFile.percent = 100;
canceledFile.action = "uploaded";
this.currentUploadNumber -= 1;
this.uploadedFilesHistory = uploadedFilesHistory;
this.percent = newPercent;
const nextFileIndex = this.files.findIndex((f) => !f.inAction);
if (nextFileIndex !== -1) {
this.startSessionFunc(nextFileIndex, t);
}
});
return;
}
const newFiles = this.files.filter((el) => el.uniqueId !== id);
const uploadedFilesHistory = this.uploadedFilesHistory.filter(
(el) => el.uniqueId !== id
@ -543,7 +567,7 @@ class UploadDataStore {
this.setConversionPercent(percent, !!error);
if (!file.error && file.fileInfo.version > 2) {
this.filesStore.setHighlightFile({
this.filesStore.setHighlightFile({
highlightFileId: file.fileInfo.id,
isFileHasExst: !file.fileInfo.fileExst,
});