Skip to content

Commit

Permalink
Web: files: Function transfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaLopaeva committed Nov 9, 2021
1 parent c30597f commit 57f65b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
27 changes: 9 additions & 18 deletions products/ASC.Files/Client/src/store/FilesActionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,22 @@ class FilesActionStore {
}
};

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;
const {
filter,
fetchFiles,
isEmptyLastPageAfterOperation,
resetFilterPage,
} = this.filesStore;

let newFilter;

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

fetchFiles(
Expand Down Expand Up @@ -336,7 +327,7 @@ class FilesActionStore {
label: translations.deleteOperation,
alert: false,
});
debugger;

try {
await this.deleteItemOperation(isFile, itemId, translations);
} catch (err) {
Expand Down
18 changes: 17 additions & 1 deletion products/ASC.Files/Client/src/store/FilesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,22 @@ class FilesStore {
);
};

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

resetFilterPage = () => {
let newFilter;
newFilter = this.filter.clone();
newFilter.page--;

return newFilter;
};

fetchFiles = (
folderId,
filter,
Expand All @@ -287,7 +303,7 @@ class FilesStore {
const filterStorageItem = localStorage.getItem(
`UserFilter=${this.userStore.user.id}`
);

console.log("FETCH");
if (filterStorageItem && !filter) {
const splitFilter = filterStorageItem.split(",");

Expand Down

0 comments on commit 57f65b4

Please sign in to comment.