Web: Files: fixed delete operation

This commit is contained in:
Nikita Gopienko 2022-12-15 11:24:44 +03:00
parent 6272250e63
commit aee7ec028e

View File

@ -27,6 +27,7 @@ import { isDesktop } from "@docspace/components/utils/device";
import { getContextMenuKeysByType } from "SRC_DIR/helpers/plugins";
import { PluginContextMenuItemType } from "SRC_DIR/helpers/plugins/constants";
import { getArchiveRoomRoleActions } from "@docspace/common/utils/actions";
import debounce from "lodash.debounce";
const { FilesFilter, RoomsFilter } = api;
const storageViewAs = localStorage.getItem("viewAs");
@ -97,6 +98,7 @@ class FilesStore {
isEmptyPage = false;
tempActionFilesIds = [];
operationAction = false;
constructor(
@ -199,15 +201,23 @@ class FilesStore {
this.files[foundIndex].title
);
this.setFiles(
this.files.filter((_, index) => {
return index !== foundIndex;
})
);
// this.setFiles(
// this.files.filter((_, index) => {
// return index !== foundIndex;
// })
// );
const newFilter = this.filter.clone();
newFilter.total -= 1;
this.setFilter(newFilter);
// const newFilter = this.filter.clone();
// newFilter.total -= 1;
// this.setFilter(newFilter);
const tempActionFilesIds = JSON.parse(
JSON.stringify(this.tempActionFilesIds)
);
tempActionFilesIds.push(this.files[foundIndex].id);
this.setTempActionFilesIds(tempActionFilesIds);
this.debounceRemoveFiles();
// Hide pagination when deleting files
runInAction(() => {
@ -316,6 +326,14 @@ class FilesStore {
});
}
debounceRemoveFiles = debounce(() => {
this.removeFiles(this.tempActionFilesIds);
}, 1000);
setTempActionFilesIds = (tempActionFilesIds) => {
this.tempActionFilesIds = tempActionFilesIds;
};
setOperationAction = (operationAction) => {
this.operationAction = operationAction;
};
@ -1830,6 +1848,7 @@ class FilesStore {
})
.finally(() => {
this.setOperationAction(false);
this.setTempActionFilesIds([]);
});
};