// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { SetLocalAudioType, SetLocalPreviewType, SetLocalVideoType, } from '../state/ducks/calling'; import { CallingButton, CallingButtonType, TooltipDirection, } from './CallingButton'; import { CallBackgroundBlur } from './CallBackgroundBlur'; import { LocalizerType } from '../types/Util'; import { ColorType } from '../types/Colors'; export type PropsType = { availableCameras: Array; conversation: { title: string; }; hasLocalAudio: boolean; hasLocalVideo: boolean; i18n: LocalizerType; isGroupCall: boolean; me: { avatarPath?: string; color?: ColorType; }; onCallCanceled: () => void; onJoinCall: () => void; setLocalAudio: (_: SetLocalAudioType) => void; setLocalVideo: (_: SetLocalVideoType) => void; setLocalPreview: (_: SetLocalPreviewType) => void; toggleParticipants: () => void; toggleSettings: () => void; }; export const CallingLobby = ({ availableCameras, conversation, hasLocalAudio, hasLocalVideo, i18n, isGroupCall = false, me, onCallCanceled, onJoinCall, setLocalAudio, setLocalPreview, setLocalVideo, toggleParticipants, toggleSettings, }: PropsType): JSX.Element => { const localVideoRef = React.useRef(null); const toggleAudio = React.useCallback((): void => { setLocalAudio({ enabled: !hasLocalAudio }); }, [hasLocalAudio, setLocalAudio]); const toggleVideo = React.useCallback((): void => { setLocalVideo({ enabled: !hasLocalVideo }); }, [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 (
{conversation.title}
{isGroupCall ? (
{hasLocalVideo && availableCameras.length > 0 ? (
); };