Fix batch rooms archive/restore operations
This commit is contained in:
parent
aa893910d6
commit
e6944339f5
@ -10,6 +10,7 @@ import {
|
||||
removeFiles,
|
||||
removeShareFiles,
|
||||
createFolder,
|
||||
moveToFolder,
|
||||
} from "@docspace/common/api/files";
|
||||
import { deleteRoom } from "@docspace/common/api/rooms";
|
||||
import {
|
||||
@ -915,16 +916,16 @@ class FilesActionStore {
|
||||
};
|
||||
|
||||
setArchiveAction = async (action, folders, t) => {
|
||||
const {
|
||||
addActiveItems,
|
||||
moveRoomToArchive,
|
||||
removeRoomFromArchive,
|
||||
setSelected,
|
||||
} = this.filesStore;
|
||||
const { addActiveItems, setSelected } = this.filesStore;
|
||||
|
||||
const { setSelectedFolder } = this.selectedFolderStore;
|
||||
|
||||
const { roomsFolder, isRoomsFolder } = this.treeFoldersStore;
|
||||
const {
|
||||
roomsFolder,
|
||||
isRoomsFolder,
|
||||
archiveRoomsId,
|
||||
myRoomsId,
|
||||
} = this.treeFoldersStore;
|
||||
const { setPortalQuota } = this.authStore.currentQuotaStore;
|
||||
|
||||
const {
|
||||
@ -936,6 +937,11 @@ class FilesActionStore {
|
||||
clearSecondaryProgressData,
|
||||
} = secondaryProgressDataStore;
|
||||
|
||||
if (!myRoomsId || !archiveRoomsId) {
|
||||
console.error("Default categories not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const items = Array.isArray(folders)
|
||||
? folders.map((x) => (x?.id ? x.id : x))
|
||||
: [folders.id];
|
||||
@ -950,15 +956,9 @@ class FilesActionStore {
|
||||
|
||||
addActiveItems(null, items);
|
||||
|
||||
const actions = [];
|
||||
|
||||
switch (action) {
|
||||
case "archive":
|
||||
items.forEach((item) => {
|
||||
actions.push(moveRoomToArchive(item));
|
||||
});
|
||||
|
||||
return Promise.all(actions)
|
||||
return moveToFolder(archiveRoomsId, items)
|
||||
.then(async (res) => {
|
||||
if (res[0]?.error) return Promise.reject(res[0].error);
|
||||
|
||||
@ -997,10 +997,7 @@ class FilesActionStore {
|
||||
})
|
||||
.finally(() => clearActiveOperations(null, items));
|
||||
case "unarchive":
|
||||
items.forEach((item) => {
|
||||
actions.push(removeRoomFromArchive(item));
|
||||
});
|
||||
return Promise.all(actions)
|
||||
return moveToFolder(myRoomsId, items)
|
||||
.then(async (res) => {
|
||||
if (res[0]?.error) return Promise.reject(res[0].error);
|
||||
|
||||
|
@ -906,9 +906,9 @@ class FilesStore {
|
||||
if (
|
||||
data.current.providerKey &&
|
||||
data.current.rootFolderType === Rooms &&
|
||||
this.treeFoldersStore.sharedRoomId
|
||||
this.treeFoldersStore.myRoomsId
|
||||
) {
|
||||
folderId = this.treeFoldersStore.sharedRoomId;
|
||||
folderId = this.treeFoldersStore.myRoomsId;
|
||||
}
|
||||
|
||||
const folderInfo =
|
||||
@ -2716,10 +2716,6 @@ class FilesStore {
|
||||
});
|
||||
};
|
||||
|
||||
moveRoomToArchive = (id) => api.rooms.archiveRoom(id);
|
||||
|
||||
removeRoomFromArchive = (id) => api.rooms.unarchiveRoom(id);
|
||||
|
||||
pinRoom = (id) => api.rooms.pinRoom(id);
|
||||
|
||||
unpinRoom = (id) => api.rooms.unpinRoom(id);
|
||||
|
@ -73,10 +73,14 @@ class TreeFoldersStore {
|
||||
|
||||
getSubfolders = (folderId) => getSubfolders(folderId);
|
||||
|
||||
get sharedRoomId() {
|
||||
get myRoomsId() {
|
||||
return this.rootFoldersTitles[FolderType.Rooms]?.id;
|
||||
}
|
||||
|
||||
get archiveRoomsId() {
|
||||
return this.rootFoldersTitles[FolderType.Archive]?.id;
|
||||
}
|
||||
|
||||
get myFolder() {
|
||||
return this.treeFolders.find((x) => x.rootFolderType === FolderType.USER);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user