Skip to content

Commit

Permalink
Web: Files: Removed empty page when deleted all files at last page.
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaLopaeva committed Nov 8, 2021
1 parent 9d0de00 commit c30597f
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions products/ASC.Files/Client/src/store/FilesActionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,39 @@ class FilesActionStore {
}
};

updateCurrentFolder = () => {
isEmptyLastPageAfterOperation = (selectionLength) => {
const { filter, files, folders } = this.filesStore;

return (
filter.page > 0 &&
!filter.hasNext() &&
selectionLength === files.length + folders.length
);
};

updateCurrentFolder = (selectionLength) => {
const {
clearSecondaryProgressData,
} = this.uploadDataStore.secondaryProgressDataStore;

const { filter, fetchFiles } = this.filesStore;
fetchFiles(this.selectedFolderStore.id, filter, true, true).finally(() =>
setTimeout(() => clearSecondaryProgressData(), TIMEOUT)
);

let newFilter;

if (
selectionLength &&
this.isEmptyLastPageAfterOperation(selectionLength)
) {
newFilter = filter.clone();
newFilter.page--;
}

fetchFiles(
this.selectedFolderStore.id,
newFilter ? newFilter : filter,
true,
true
).finally(() => setTimeout(() => clearSecondaryProgressData(), TIMEOUT));
};

deleteAction = async (translations, newSelection = null) => {
Expand Down Expand Up @@ -113,7 +137,7 @@ class FilesActionStore {
label: translations.deleteOperation,
};
await this.uploadDataStore.loopFilesOperations(data, pbData);
this.updateCurrentFolder();
this.updateCurrentFolder(selection.length);
}
);
} catch (err) {
Expand Down Expand Up @@ -312,7 +336,7 @@ class FilesActionStore {
label: translations.deleteOperation,
alert: false,
});

debugger;
try {
await this.deleteItemOperation(isFile, itemId, translations);
} catch (err) {
Expand All @@ -331,7 +355,7 @@ class FilesActionStore {
icon: "trash",
label: translations.deleteOperation,
};

console.log("deleteItemOperation");
if (isFile) {
this.isMediaOpen();
return deleteFile(itemId)
Expand Down

0 comments on commit c30597f

Please sign in to comment.