Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getUserDisplayName, VideoConferenceStatus } from '@rocket.chat/core-typings';
import { Box, States, StatesAction, StatesActions, StatesIcon, StatesSubtitle, StatesTitle } from '@rocket.chat/fuselage';
import { useGoToRoom, useSetting, useTranslation, useUserId, useUserPreference } from '@rocket.chat/ui-contexts';
import type * as UiKit from '@rocket.chat/ui-kit';
import {
Expand Down Expand Up @@ -27,6 +28,8 @@ type VideoConferenceBlockProps = BlockProps<UiKit.VideoConferenceBlock>;

const MAX_USERS = 3;

const getErrorMessage = (error: unknown): string | undefined => (error instanceof Error ? error.message : undefined);

const VideoConferenceBlock = ({ block }: VideoConferenceBlockProps): ReactElement => {
const t = useTranslation();
const { callId, appId = 'videoconf-core' } = block;
Expand Down Expand Up @@ -109,11 +112,33 @@ const VideoConferenceBlock = ({ block }: VideoConferenceBlockProps): ReactElemen
: t('joined');
}, [displayAvatars, t, result.data?.users.length]);

if (result.isPending || result.isError) {
// TODO: error handling
if (result.isPending) {
return <VideoConfMessageSkeleton />;
}

if (result.isError) {
const errorMessage = getErrorMessage(result.error);

return (
<VideoConfMessage>
<VideoConfMessageRow>
<VideoConfMessageContent>
<Box display='flex' flexDirection='column' alignItems='center'>
<States>
<StatesIcon name='warning' variation='danger' />
<StatesTitle>{t('Something_went_wrong')}</StatesTitle>
<StatesSubtitle>{errorMessage ?? t('Unable_to_retrieve_data')}</StatesSubtitle>
<StatesActions>
<StatesAction onClick={() => result.refetch()}>{t('Retry')}</StatesAction>
</StatesActions>
</States>
</Box>
</VideoConfMessageContent>
</VideoConfMessageRow>
</VideoConfMessage>
);
}

const { data } = result;
const isUserCaller = data.createdBy._id === userId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { VideoConference, VideoConferenceCapabilities } from '@rocket.chat/core-typings';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';

type VideoConfInfo = VideoConference & { capabilities: VideoConferenceCapabilities };

export const useVideoConfData = ({ callId }: { callId: string }) => {
const getVideoConfInfo = useEndpoint('GET', '/v1/video-conference.info');

return useQuery({
return useQuery<VideoConfInfo, Error>({
queryKey: ['video-conference', callId],
queryFn: () => getVideoConfInfo({ callId }),
staleTime: Infinity,
Expand Down