Skip to content
Snippets Groups Projects
Unverified Commit b763c371 authored by Douglas Fabris's avatar Douglas Fabris Committed by GitHub
Browse files

refactor: Replace `useEndpointData` in VideoConf incoming popup (#35060)

parent 6d78d701
No related branches found
No related tags found
No related merge requests found
import type { IRoom } from '@rocket.chat/core-typings';
import { Skeleton } from '@rocket.chat/fuselage';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import {
useVideoConfSetPreferences,
VideoConfPopup,
......@@ -14,13 +15,11 @@ import {
VideoConfPopupTitle,
VideoConfPopupHeader,
} from '@rocket.chat/ui-video-conf';
import { useQuery } from '@tanstack/react-query';
import type { ReactElement } from 'react';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import VideoConfPopupRoomInfo from './VideoConfPopupRoomInfo';
import { AsyncStatePhase } from '../../../../../../hooks/useAsyncState';
import { useEndpointData } from '../../../../../../hooks/useEndpointData';
type IncomingPopupProps = {
id: string;
......@@ -36,10 +35,14 @@ const IncomingPopup = ({ id, room, position, onClose, onMute, onConfirm }: Incom
const { controllersConfig, handleToggleMic, handleToggleCam } = useVideoConfControllers();
const setPreferences = useVideoConfSetPreferences();
const params = useMemo(() => ({ callId: id }), [id]);
const { phase, value } = useEndpointData('/v1/video-conference.info', { params });
const showMic = Boolean(value?.capabilities?.mic);
const showCam = Boolean(value?.capabilities?.cam);
const videoConfInfo = useEndpoint('GET', '/v1/video-conference.info');
const { data, isPending, isSuccess } = useQuery({
queryKey: ['getVideoConferenceInfo', id],
queryFn: async () => videoConfInfo({ callId: id }),
});
const showMic = Boolean(data?.capabilities?.mic);
const showCam = Boolean(data?.capabilities?.cam);
const handleJoinCall = useEffectEvent(() => {
setPreferences(controllersConfig);
......@@ -50,8 +53,8 @@ const IncomingPopup = ({ id, room, position, onClose, onMute, onConfirm }: Incom
<VideoConfPopup position={position}>
<VideoConfPopupHeader>
<VideoConfPopupTitle text={t('Incoming_call_from')} />
{phase === AsyncStatePhase.LOADING && <Skeleton />}
{phase === AsyncStatePhase.RESOLVED && (showMic || showCam) && (
{isPending && <Skeleton />}
{isSuccess && (showMic || showCam) && (
<VideoConfPopupControllers>
{showCam && (
<VideoConfController
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment