/* eslint-disable no-underscore-dangle */ /* eslint-disable @typescript-eslint/ban-ts-comment */ import React, { useCallback, useEffect, useMemo } from 'react'; import { User } from '/imports/ui/Types/user'; import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser'; import useMeeting from '/imports/ui/core/hooks/useMeeting'; import { Meeting } from '/imports/ui/Types/meeting'; import { useShortcut } from '/imports/ui/core/hooks/useShortcut'; import { useMutation, useReactiveVar } from '@apollo/client'; import { defineMessages, useIntl } from 'react-intl'; import Button from '/imports/ui/components/common/button/component'; import AudioModalContainer from '../../audio-modal/container'; import AudioManager from '/imports/ui/services/audio-manager'; import { joinListenOnly } from './service'; import Styled from './styles'; import InputStreamLiveSelectorContainer from './input-stream-live-selector/component'; import { UPDATE_ECHO_TEST_RUNNING } from './queries'; const intlMessages = defineMessages({ joinAudio: { id: 'app.audio.joinAudio', description: 'Join audio button label', }, joinAudioAndSetActive: { id: 'app.audio.joinAudioAndSetActive', description: 'Join audio button label when user is away', }, leaveAudio: { id: 'app.audio.leaveAudio', description: 'Leave audio button label', }, muteAudio: { id: 'app.actionsBar.muteLabel', description: 'Mute audio button label', }, unmuteAudio: { id: 'app.actionsBar.unmuteLabel', description: 'Unmute audio button label', }, }); interface AudioControlsProps { inAudio: boolean; isConnected: boolean; disabled: boolean; isEchoTest: boolean; updateEchoTestRunning: () => void, away: boolean; } const AudioControls: React.FC = ({ isConnected, disabled, inAudio, isEchoTest, updateEchoTestRunning, away, }) => { const intl = useIntl(); const joinAudioShortcut = useShortcut('joinAudio'); const echoTestIntervalRef = React.useRef>(); const [isAudioModalOpen, setIsAudioModalOpen] = React.useState(false); const handleJoinAudio = useCallback((connected: boolean) => { if (connected) { joinListenOnly(); } else { setIsAudioModalOpen(true); } }, []); const joinButton = useMemo(() => { const joinAudioLabel = away ? intlMessages.joinAudioAndSetActive : intlMessages.joinAudio; return ( // eslint-disable-next-line jsx-a11y/no-access-key