From 63de7dfa21a1c35c23f5c870e2a610421eed220a Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Fri, 16 Aug 2024 10:13:38 +0300 Subject: [PATCH] Refactoring. --- .../src/components/FilesPanels/index.js | 33 ++++++++++++------- .../components/panels/InvitePanel/index.js | 8 ++--- .../client/src/store/CreateEditRoomStore.js | 2 +- packages/client/src/store/DialogsStore.js | 8 +++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/packages/client/src/components/FilesPanels/index.js b/packages/client/src/components/FilesPanels/index.js index f57da96f72..3f2ec26935 100644 --- a/packages/client/src/components/FilesPanels/index.js +++ b/packages/client/src/components/FilesPanels/index.js @@ -81,7 +81,6 @@ import { PDFFormEditingDialog } from "../dialogs/PDFFormEditingDialog"; import { SharePDFFormDialog } from "../dialogs/SharePDFFormDialog"; import { FillPDFDialog } from "../dialogs/FillPDFDialog"; import { ShareCollectSelector } from "../ShareCollectSelector"; -import { currentQuotaStore } from "@docspace/shared/store"; const Panels = (props) => { const { @@ -138,10 +137,11 @@ const Panels = (props) => { selectFileFormRoomOpenRoot, fillPDFDialogData, shareCollectSelector, + setQuotaWarningDialogVisible, - setIsNewQuotaItemsByCurrentUser, - isNewQuotaItemsByCurrentUser, isItemTariffAlmostLimit, + resetQuotaItem, + isNewItemByCurrentUser, } = props; const [sharePDFForm, setSharePDFForm] = useState({ @@ -198,14 +198,15 @@ const Panels = (props) => { }, [handleSharePDFForm]); useEffect(() => { - if (isNewQuotaItemsByCurrentUser) { + if (isNewItemByCurrentUser) { isItemTariffAlmostLimit && setQuotaWarningDialogVisible(true); - setIsNewQuotaItemsByCurrentUser(false); + + resetQuotaItem(); } return () => { - setIsNewQuotaItemsByCurrentUser(false); + resetQuotaItem(); }; - }, [isItemTariffAlmostLimit, isNewQuotaItemsByCurrentUser]); + }, [isItemTariffAlmostLimit, isNewItemByCurrentUser]); return [ settingsPluginDialogVisible && ( @@ -397,8 +398,10 @@ export default inject( shareCollectSelector, setQuotaWarningDialogVisible, - setIsNewQuotaItemsByCurrentUser, - isNewQuotaItemsByCurrentUser, + setIsNewRoomByCurrentUser, + setIsNewUserByCurrentUser, + isNewUserByCurrentUser, + isNewRoomByCurrentUser, } = dialogsStore; const { preparationPortalDialogVisible } = backup; @@ -421,6 +424,14 @@ export default inject( const isItemTariffAlmostLimit = isAccounts ? isUserTariffAlmostLimit : isRoomTariffAlmostLimit; + const resetQuotaItem = () => { + if (isNewUserByCurrentUser) setIsNewUserByCurrentUser(false); + if (isNewRoomByCurrentUser) setIsNewRoomByCurrentUser(false); + }; + + const isNewItemByCurrentUser = isAccounts + ? isNewUserByCurrentUser + : isNewRoomByCurrentUser; return { preparationPortalDialogVisible, @@ -478,9 +489,9 @@ export default inject( shareCollectSelector, setQuotaWarningDialogVisible, - setIsNewQuotaItemsByCurrentUser, - isNewQuotaItemsByCurrentUser, + resetQuotaItem, isItemTariffAlmostLimit, + isNewItemByCurrentUser, }; }, )(observer(Panels)); diff --git a/packages/client/src/components/panels/InvitePanel/index.js b/packages/client/src/components/panels/InvitePanel/index.js index 2a9a63e7a2..e3b1e6da77 100644 --- a/packages/client/src/components/panels/InvitePanel/index.js +++ b/packages/client/src/components/panels/InvitePanel/index.js @@ -88,7 +88,7 @@ const InvitePanel = ({ isRoomAdmin, maxCountManagersByQuota, invitePaidUsersCount, - setIsNewQuotaItemsByCurrentUser, + setIsNewUserByCurrentUser, }) => { const [invitePanelIsLoding, setInvitePanelIsLoading] = useState( roomId !== -1, @@ -334,7 +334,7 @@ const InvitePanel = ({ : await setRoomSecurity(roomId, data); if (!isRooms) { - setIsNewQuotaItemsByCurrentUser(true); + setIsNewUserByCurrentUser(true); } setIsLoading(false); @@ -549,7 +549,7 @@ export default inject( setInvitePanelOptions, setInviteLanguage, invitePaidUsersCount, - setIsNewQuotaItemsByCurrentUser, + setIsNewUserByCurrentUser, } = dialogsStore; const { getFolderInfo, setRoomSecurity, getRoomSecurityInfo, folders } = @@ -583,7 +583,7 @@ export default inject( isRoomAdmin, maxCountManagersByQuota, invitePaidUsersCount, - setIsNewQuotaItemsByCurrentUser, + setIsNewUserByCurrentUser, }; }, )( diff --git a/packages/client/src/store/CreateEditRoomStore.js b/packages/client/src/store/CreateEditRoomStore.js index 2309285beb..b9afd866e0 100644 --- a/packages/client/src/store/CreateEditRoomStore.js +++ b/packages/client/src/store/CreateEditRoomStore.js @@ -155,7 +155,7 @@ class CreateEditRoomStore { ? await createRoomInThirdpary(storageFolderId, createRoomData) : await createRoom(createRoomData); - this.dialogsStore.setIsNewQuotaItemsByCurrentUser(true); + this.dialogsStore.setIsNewRoomByCurrentUser(true); room.isLogoLoading = true; diff --git a/packages/client/src/store/DialogsStore.js b/packages/client/src/store/DialogsStore.js index c65d01a28a..725d06a35e 100644 --- a/packages/client/src/store/DialogsStore.js +++ b/packages/client/src/store/DialogsStore.js @@ -473,8 +473,12 @@ class DialogsStore { this.inviteQuotaWarningDialogVisible = inviteQuotaWarningDialogVisible; }; - setIsNewQuotaItemsByCurrentUser = (value) => { - this.isNewQuotaItemsByCurrentUser = value; + setIsNewRoomByCurrentUser = (value) => { + this.isNewRoomByCurrentUser = value; + }; + + setIsNewUserByCurrentUser = (value) => { + this.isNewUserByCurrentUser = value; }; setCreateRoomDialogVisible = (createRoomDialogVisible) => {