From fa1a2b80fb23b3889be9add9b28b8b486e79225a Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 25 Oct 2023 19:11:53 -0300 Subject: [PATCH] review --- .../omnichannel/useMacLimitValidations.tsx | 30 ------------------- .../client/providers/OmnichannelProvider.tsx | 6 ++-- .../RoomList/SideBarItemTemplateWithData.tsx | 2 +- 3 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 apps/meteor/client/hooks/omnichannel/useMacLimitValidations.tsx diff --git a/apps/meteor/client/hooks/omnichannel/useMacLimitValidations.tsx b/apps/meteor/client/hooks/omnichannel/useMacLimitValidations.tsx deleted file mode 100644 index da2bfae69d530..0000000000000 --- a/apps/meteor/client/hooks/omnichannel/useMacLimitValidations.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { useStream } from '@rocket.chat/ui-contexts'; -import { useEffect, useState } from 'react'; - -import { useLicense } from '../useLicense'; - -export const useMacLimitValidations = (enabled: boolean) => { - const { data: { preventedActions } = {}, isLoading, isError } = useLicense(); - const [isOverMacLimit, setOverMacLimit] = useState(preventedActions?.monthlyActiveContacts || false); - const subscribe = useStream('notify-logged'); - - useEffect(() => { - if (!enabled || isLoading || isError) { - return; - } - - setOverMacLimit(preventedActions?.monthlyActiveContacts ?? false); - }, [enabled, isError, isLoading, preventedActions?.monthlyActiveContacts]); - - useEffect(() => { - if (!enabled) { - return; - } - - return subscribe(`mac.limit`, ({ limitReached }) => { - setOverMacLimit(limitReached); - }); - }, [subscribe, enabled]); - - return { isOverMacLimit }; -}; diff --git a/apps/meteor/client/providers/OmnichannelProvider.tsx b/apps/meteor/client/providers/OmnichannelProvider.tsx index c73e7f31797b1..6e7cf38f8cd58 100644 --- a/apps/meteor/client/providers/OmnichannelProvider.tsx +++ b/apps/meteor/client/providers/OmnichannelProvider.tsx @@ -19,7 +19,7 @@ import { useHasLicenseModule } from '../../ee/client/hooks/useHasLicenseModule'; import { ClientLogger } from '../../lib/ClientLogger'; import type { OmnichannelContextValue } from '../contexts/OmnichannelContext'; import { OmnichannelContext } from '../contexts/OmnichannelContext'; -import { useMacLimitValidations } from '../hooks/omnichannel/useMacLimitValidations'; +import { useLicense } from '../hooks/useLicense'; import { useReactiveValue } from '../hooks/useReactiveValue'; const emptyContextValue: OmnichannelContextValue = { @@ -76,7 +76,9 @@ const OmnichannelProvider: FC = ({ children }) => { enabled: isPrioritiesEnabled, }); - const { isOverMacLimit } = useMacLimitValidations(enabled); + const { data: { preventedActions } = {} } = useLicense(); + + const isOverMacLimit = Boolean(preventedActions?.monthlyActiveContacts); useEffect(() => { if (!isPrioritiesEnabled) { diff --git a/apps/meteor/client/sidebar/RoomList/SideBarItemTemplateWithData.tsx b/apps/meteor/client/sidebar/RoomList/SideBarItemTemplateWithData.tsx index afbd9441515ad..4c51b8a3615b8 100644 --- a/apps/meteor/client/sidebar/RoomList/SideBarItemTemplateWithData.tsx +++ b/apps/meteor/client/sidebar/RoomList/SideBarItemTemplateWithData.tsx @@ -170,7 +170,7 @@ function SideBarItemTemplateWithData({ {unread + tunread?.length} )} - + {isOmnichannelRoom(room) && } );