diff --git a/apps/meteor/client/hooks/useLicense.ts b/apps/meteor/client/hooks/useLicense.ts index ec07e1702bed0..ae965d1059586 100644 --- a/apps/meteor/client/hooks/useLicense.ts +++ b/apps/meteor/client/hooks/useLicense.ts @@ -1,29 +1,32 @@ import type { Serialized } from '@rocket.chat/core-typings'; -import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks'; import type { OperationResult } from '@rocket.chat/rest-typings'; import { useEndpoint, useSingleStream } from '@rocket.chat/ui-contexts'; -import type { UseQueryResult } from '@tanstack/react-query'; +import type { QueryClient, UseQueryResult } from '@tanstack/react-query'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useEffect } from 'react'; type LicenseDataType = Awaited>['license']; +const invalidateQueryClientLicenses = (() => { + let timeout: ReturnType | undefined; + + return (queryClient: QueryClient) => { + clearTimeout(timeout); + timeout = setTimeout(() => { + timeout = undefined; + queryClient.invalidateQueries(['licenses', 'getLicenses']); + }, 5000); + }; +})(); + export const useLicense = (): UseQueryResult> => { const getLicenses = useEndpoint('GET', '/v1/licenses.info'); const queryClient = useQueryClient(); - const invalidate = useDebouncedCallback( - () => { - queryClient.invalidateQueries(['licenses', 'getLicenses']); - }, - 5000, - [], - ); - const notify = useSingleStream('notify-all'); - useEffect(() => notify('license', () => invalidate()), [notify, invalidate]); + useEffect(() => notify('license', () => invalidateQueryClientLicenses(queryClient)), [notify, queryClient]); return useQuery(['licenses', 'getLicenses'], () => getLicenses({}), { staleTime: Infinity, diff --git a/ee/packages/license/src/v2/convertToV3.ts b/ee/packages/license/src/v2/convertToV3.ts index 10681cf04b47b..f4232c0bac4f9 100644 --- a/ee/packages/license/src/v2/convertToV3.ts +++ b/ee/packages/license/src/v2/convertToV3.ts @@ -51,7 +51,7 @@ export const convertToV3 = (v2: ILicenseV2): ILicenseV3 => { }, grantedModules: [ ...new Set( - v2.modules + ['hide-watermark', ...v2.modules] .map((licenseModule) => (isBundle(licenseModule) ? getBundleModules(licenseModule) : [licenseModule])) .reduce((prev, curr) => [...prev, ...curr], []) .map((licenseModule) => ({ module: licenseModule as LicenseModule })),