From ed2298663cb9a71e358d4b4b93e952d70857df57 Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Wed, 22 Jun 2022 17:25:26 +0300 Subject: [PATCH] Web: Files: Added opportunity to turn off "New" files badge --- .../Client/src/store/FilesActionsStore.js | 15 ++++++++++++--- products/ASC.Files/Client/src/store/FilesStore.js | 11 ++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/products/ASC.Files/Client/src/store/FilesActionsStore.js b/products/ASC.Files/Client/src/store/FilesActionsStore.js index c16cc521be..62e0c7c621 100644 --- a/products/ASC.Files/Client/src/store/FilesActionsStore.js +++ b/products/ASC.Files/Client/src/store/FilesActionsStore.js @@ -758,7 +758,7 @@ class FilesActionStore { else updateFolderBadge(id, item.new); }; - markAsRead = (folderIds, fileId, item) => { + markAsRead = (folderIds, fileIds, item) => { const { setSecondaryProgressBarData, clearSecondaryProgressData, @@ -771,13 +771,22 @@ class FilesActionStore { visible: true, }); - return markAsRead(folderIds, fileId) + return markAsRead(folderIds, fileIds) .then(async (res) => { const data = res[0] ? res[0] : null; const pbData = { icon: "file" }; await this.uploadDataStore.loopFilesOperations(data, pbData); }) - .then(() => item && this.setNewBadgeCount(item)) + .then(() => { + if (!item) return; + + this.setNewBadgeCount(item); + + const { getFileIndex, updateFileStatus } = this.filesStore; + + const index = getFileIndex(item.id); + updateFileStatus(index, item.fileStatus & ~FileStatus.IsNew); + }) .catch((err) => toastr.error(err)) .finally(() => setTimeout(() => clearSecondaryProgressData(), TIMEOUT)); }; diff --git a/products/ASC.Files/Client/src/store/FilesStore.js b/products/ASC.Files/Client/src/store/FilesStore.js index 0cbda8ed0d..7901f1f5b9 100644 --- a/products/ASC.Files/Client/src/store/FilesStore.js +++ b/products/ASC.Files/Client/src/store/FilesStore.js @@ -404,12 +404,13 @@ class FilesStore { this.folders = folders; }; - updateFileStatus = (index, status, file) => { - if (index < 0) return; + getFileIndex = (id) => { + const index = this.files.findIndex((x) => x.id === id); + return index; + }; - if (file) { - this.files[index] = file; - } + updateFileStatus = (index, status) => { + if (index < 0) return; this.files[index].fileStatus = status; };