diff --git a/apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.tsx b/apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.tsx index 84e3d62b38ec..50b3c85ea634 100644 --- a/apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.tsx +++ b/apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.tsx @@ -1,3 +1,4 @@ +import type { IRoom } from '@rocket.chat/core-typings'; import { Box, Modal, @@ -25,7 +26,6 @@ import { useToastMessageDispatch, usePermissionWithScopedRoles, } from '@rocket.chat/ui-contexts'; -import { useQuery } from '@tanstack/react-query'; import type { ComponentProps, ReactElement } from 'react'; import React, { useEffect, useMemo } from 'react'; import { useForm, Controller } from 'react-hook-form'; @@ -37,6 +37,7 @@ import { useEncryptedRoomDescription } from '../hooks/useEncryptedRoomDescriptio type CreateChannelModalProps = { teamId?: string; + mainRoom?: IRoom; onClose: () => void; reload?: () => void; }; @@ -62,7 +63,7 @@ const getFederationHintKey = (licenseModule: ReturnType { +const CreateChannelModal = ({ teamId = '', mainRoom, onClose, reload }: CreateChannelModalProps): ReactElement => { const t = useTranslation(); const canSetReadOnly = usePermissionWithScopedRoles('set-readonly', ['owner']); const e2eEnabled = useSetting('E2E_Enable'); @@ -79,19 +80,12 @@ const CreateChannelModal = ({ teamId = '', onClose, reload }: CreateChannelModal const federatedModule = useHasLicenseModule('federation'); const canUseFederation = federatedModule !== 'loading' && federatedModule && federationEnabled; - const teamsInfoEndpoint = useEndpoint('GET', '/v1/teams.info'); const channelNameExists = useEndpoint('GET', '/v1/rooms.nameExists'); const createChannel = useEndpoint('POST', '/v1/channels.create'); const createPrivateChannel = useEndpoint('POST', '/v1/groups.create'); - const { data: teamInfoData } = useQuery(['teamId', teamId], async () => teamsInfoEndpoint({ teamId }), { - keepPreviousData: true, - retry: false, - enabled: teamId !== '', - }); - - const canCreateTeamChannel = usePermission('create-team-channel', teamInfoData?.teamInfo.roomId); - const canCreateTeamGroup = usePermission('create-team-group', teamInfoData?.teamInfo.roomId); + const canCreateTeamChannel = usePermission('create-team-channel', mainRoom?._id); + const canCreateTeamGroup = usePermission('create-team-group', mainRoom?._id); const dispatchToastMessage = useToastMessageDispatch(); diff --git a/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannelsWithData.tsx b/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannelsWithData.tsx index 9a4b66bf30de..731a4fbd1a6e 100644 --- a/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannelsWithData.tsx +++ b/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannelsWithData.tsx @@ -45,7 +45,7 @@ const TeamsChannelsWithData = () => { }); const handleCreateNew = useEffectEvent(() => { - setModal( setModal(null)} reload={reload} />); + setModal( setModal(null)} reload={reload} />); }); const goToRoom = useEffectEvent((room: IRoom) => {