import React from 'react'; import { CallDetailsType, SetLocalAudioType, SetLocalPreviewType, SetLocalVideoType, } from '../state/ducks/calling'; import { CallingButton, CallingButtonType, TooltipDirection, } from './CallingButton'; import { CallBackgroundBlur } from './CallBackgroundBlur'; import { LocalizerType } from '../types/Util'; export type PropsType = { availableCameras: Array; callDetails: CallDetailsType; hasLocalAudio: boolean; hasLocalVideo: boolean; i18n: LocalizerType; isGroupCall: boolean; onCallCanceled: () => void; onJoinCall: () => void; setLocalAudio: (_: SetLocalAudioType) => void; setLocalVideo: (_: SetLocalVideoType) => void; setLocalPreview: (_: SetLocalPreviewType) => void; toggleParticipants: () => void; toggleSettings: () => void; }; export const CallingLobby = ({ availableCameras, callDetails, hasLocalAudio, hasLocalVideo, i18n, isGroupCall = false, onCallCanceled, onJoinCall, setLocalAudio, setLocalPreview, setLocalVideo, toggleParticipants, toggleSettings, }: PropsType): JSX.Element => { const localVideoRef = React.useRef(null); const toggleAudio = React.useCallback((): void => { if (!callDetails) { return; } setLocalAudio({ enabled: !hasLocalAudio }); }, [callDetails, hasLocalAudio, setLocalAudio]); const toggleVideo = React.useCallback((): void => { if (!callDetails) { return; } setLocalVideo({ enabled: !hasLocalVideo }); }, [callDetails, hasLocalVideo, setLocalVideo]); React.useEffect(() => { setLocalPreview({ element: localVideoRef }); return () => { setLocalPreview({ element: undefined }); }; }, [setLocalPreview]); React.useEffect(() => { function handleKeyDown(event: KeyboardEvent): void { let eventHandled = false; if (event.shiftKey && (event.key === 'V' || event.key === 'v')) { toggleVideo(); eventHandled = true; } else if (event.shiftKey && (event.key === 'M' || event.key === 'm')) { toggleAudio(); eventHandled = true; } if (eventHandled) { event.preventDefault(); event.stopPropagation(); } } document.addEventListener('keydown', handleKeyDown); return () => { document.removeEventListener('keydown', handleKeyDown); }; }, [toggleVideo, toggleAudio]); // eslint-disable-next-line no-nested-ternary const videoButtonType = hasLocalVideo ? CallingButtonType.VIDEO_ON : availableCameras.length === 0 ? CallingButtonType.VIDEO_DISABLED : CallingButtonType.VIDEO_OFF; const audioButtonType = hasLocalAudio ? CallingButtonType.AUDIO_ON : CallingButtonType.AUDIO_OFF; return (
{callDetails.title}
{isGroupCall ? (
{hasLocalVideo && availableCameras.length > 0 ? (
); };