2024-06-13 04:44:52 +08:00
|
|
|
import React, { useCallback } from 'react';
|
2024-06-12 21:25:46 +08:00
|
|
|
import { useReactiveVar } from '@apollo/client';
|
2021-04-01 19:14:24 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
2018-09-14 02:09:30 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2017-09-29 21:38:10 +08:00
|
|
|
import AudioModal from './component';
|
2019-09-30 22:54:34 +08:00
|
|
|
import AudioError from '/imports/ui/services/audio-manager/error-codes';
|
2020-03-03 04:49:15 +08:00
|
|
|
import AppService from '/imports/ui/components/app/service';
|
|
|
|
import {
|
|
|
|
joinMicrophone,
|
|
|
|
closeModal,
|
|
|
|
joinListenOnly,
|
|
|
|
leaveEchoTest,
|
|
|
|
} from './service';
|
2017-09-29 21:38:10 +08:00
|
|
|
import Service from '../service';
|
2024-04-04 22:47:01 +08:00
|
|
|
import AudioModalService from '/imports/ui/components/audio/audio-modal/service';
|
2024-05-14 21:31:05 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-06-12 21:25:46 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
2024-06-06 21:50:03 +08:00
|
|
|
import { useStorageKey } from '/imports/ui/services/storage/hooks';
|
2024-06-13 04:44:52 +08:00
|
|
|
import useMeeting from '/imports/ui/core/hooks/useMeeting';
|
|
|
|
import useLockContext from '/imports/ui/components/lock-viewers/hooks/useLockContext';
|
2024-04-16 02:14:19 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2024-06-13 04:44:52 +08:00
|
|
|
|
|
|
|
const invalidDialNumbers = ['0', '613-555-1212', '613-555-1234', '0000'];
|
2017-09-29 21:38:10 +08:00
|
|
|
|
2024-05-14 21:31:05 +08:00
|
|
|
const AudioModalContainer = (props) => {
|
2024-06-13 04:44:52 +08:00
|
|
|
const { data: meeting } = useMeeting((m) => ({
|
|
|
|
voiceSettings: m.voiceSettings,
|
|
|
|
}));
|
2024-05-14 21:31:05 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
away: user.away,
|
2024-05-29 21:26:11 +08:00
|
|
|
isModerator: user.isModerator,
|
2024-05-14 21:31:05 +08:00
|
|
|
}));
|
2024-06-06 21:50:03 +08:00
|
|
|
const getEchoTest = useStorageKey('getEchoTest', 'session');
|
2024-05-14 21:31:05 +08:00
|
|
|
|
|
|
|
const away = currentUserData?.away;
|
2024-05-29 21:26:11 +08:00
|
|
|
const isModerator = currentUserData?.isModerator;
|
2024-05-14 21:31:05 +08:00
|
|
|
|
2024-06-13 04:44:52 +08:00
|
|
|
const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
2024-05-29 21:26:11 +08:00
|
|
|
const APP_CONFIG = window.meetingClientSettings.public.app;
|
|
|
|
const forceListenOnly = getFromUserSettings('bbb_force_listen_only', APP_CONFIG.forceListenOnly);
|
2024-06-13 04:44:52 +08:00
|
|
|
const listenOnlyMode = getFromUserSettings('bbb_listen_only_mode', APP_CONFIG.listenOnlyMode);
|
|
|
|
const skipCheck = getFromUserSettings('bbb_skip_check_audio', APP_CONFIG.skipCheck);
|
|
|
|
const skipCheckOnJoin = getFromUserSettings('bbb_skip_check_audio_on_first_join', APP_CONFIG.skipCheckOnJoin);
|
2024-04-16 02:14:19 +08:00
|
|
|
// Mobile users have significant trouble figuring out correct audio I/O devices
|
|
|
|
// according to feedbacks. The potential absence of echo test after having set
|
|
|
|
// an initial device in the first join cycle might complicate things even further
|
|
|
|
// if they got it wrong. Hence, we ignore the flag for mobile users.
|
2024-07-19 22:29:38 +08:00
|
|
|
const skipEchoTestIfPreviousDevice = getFromUserSettings(
|
|
|
|
'bbb_skip_echotest_if_previous_device',
|
|
|
|
APP_CONFIG.skipEchoTestIfPreviousDevice,
|
2024-04-16 02:14:19 +08:00
|
|
|
) && !deviceInfo.isMobile;
|
2024-06-13 04:44:52 +08:00
|
|
|
const autoJoin = getFromUserSettings('bbb_auto_join_audio', APP_CONFIG.autoJoin);
|
|
|
|
|
|
|
|
let formattedDialNum = '';
|
|
|
|
let formattedTelVoice = '';
|
|
|
|
let combinedDialInNum = '';
|
|
|
|
if (meeting && meeting.voiceSettings) {
|
|
|
|
const { dialNumber, telVoice } = meeting.voiceSettings;
|
|
|
|
if (invalidDialNumbers.indexOf(dialNumber) < 0) {
|
|
|
|
formattedDialNum = dialNumber;
|
|
|
|
formattedTelVoice = telVoice;
|
|
|
|
combinedDialInNum = `${dialNumber.replace(/\D+/g, '')},,,${telVoice.replace(/\D+/g, '')}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const { isIe } = browserInfo;
|
|
|
|
|
|
|
|
const SHOW_VOLUME_METER = window.meetingClientSettings.public.media.showVolumeMeter;
|
|
|
|
|
|
|
|
const {
|
|
|
|
enabled: LOCAL_ECHO_TEST_ENABLED,
|
|
|
|
} = window.meetingClientSettings.public.media.localEchoTest;
|
2020-03-03 04:49:15 +08:00
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
const forceListenOnlyAttendee = forceListenOnly && !isModerator;
|
2024-06-12 21:25:46 +08:00
|
|
|
const inputDeviceId = useReactiveVar(AudioManager._inputDeviceId.value);
|
|
|
|
const outputDeviceId = useReactiveVar(AudioManager._outputDeviceId.value);
|
|
|
|
const showPermissionsOvelay = useReactiveVar(AudioManager._isWaitingPermissions.value);
|
|
|
|
const isUsingAudio = Service.useIsUsingAudio();
|
|
|
|
const isConnecting = useReactiveVar(AudioManager._isConnecting.value);
|
|
|
|
const isConnected = useReactiveVar(AudioManager._isConnected.value);
|
|
|
|
const isListenOnly = useReactiveVar(AudioManager._isListenOnly.value);
|
|
|
|
const isEchoTest = useReactiveVar(AudioManager._isEchoTest.value);
|
|
|
|
const autoplayBlocked = useReactiveVar(AudioManager._autoplayBlocked.value);
|
2024-06-13 04:44:52 +08:00
|
|
|
const meetingIsBreakout = AppService.useMeetingIsBreakout();
|
|
|
|
const { userLocks } = useLockContext();
|
2024-05-29 21:26:11 +08:00
|
|
|
|
2024-06-13 04:44:52 +08:00
|
|
|
const { setIsOpen } = props;
|
|
|
|
const close = useCallback(() => closeModal(() => setIsOpen(false)), [setIsOpen]);
|
|
|
|
const joinMic = useCallback(
|
|
|
|
(skipEchoTest) => joinMicrophone(skipEchoTest || skipCheck || skipCheckOnJoin),
|
|
|
|
[skipCheck, skipCheckOnJoin],
|
|
|
|
);
|
2024-06-06 21:50:03 +08:00
|
|
|
const joinFullAudioImmediately = (
|
|
|
|
autoJoin
|
|
|
|
&& (
|
|
|
|
skipCheck
|
|
|
|
|| (skipCheckOnJoin && !getEchoTest)
|
|
|
|
))
|
|
|
|
|| (
|
|
|
|
skipCheck
|
|
|
|
|| (skipCheckOnJoin && !getEchoTest)
|
2024-07-19 22:29:38 +08:00
|
|
|
|| (skipEchoTestIfPreviousDevice && (inputDeviceId || outputDeviceId))
|
2024-06-06 21:50:03 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AudioModal
|
|
|
|
away={away}
|
|
|
|
forceListenOnlyAttendee={forceListenOnlyAttendee}
|
2024-06-12 21:25:46 +08:00
|
|
|
inputDeviceId={inputDeviceId}
|
|
|
|
outputDeviceId={outputDeviceId}
|
|
|
|
showPermissionsOvelay={showPermissionsOvelay}
|
|
|
|
isUsingAudio={isUsingAudio}
|
|
|
|
isConnecting={isConnecting}
|
|
|
|
isConnected={isConnected}
|
|
|
|
isListenOnly={isListenOnly}
|
|
|
|
isEchoTest={isEchoTest}
|
|
|
|
autoplayBlocked={autoplayBlocked}
|
2024-06-06 21:50:03 +08:00
|
|
|
getEchoTest={getEchoTest}
|
|
|
|
joinFullAudioImmediately={joinFullAudioImmediately}
|
2024-06-13 04:44:52 +08:00
|
|
|
meetingIsBreakout={meetingIsBreakout}
|
|
|
|
closeModal={close}
|
|
|
|
joinMicrophone={joinMic}
|
|
|
|
joinListenOnly={joinListenOnly}
|
|
|
|
leaveEchoTest={leaveEchoTest}
|
|
|
|
changeInputDevice={Service.changeInputDevice}
|
|
|
|
changeInputStream={Service.changeInputStream}
|
|
|
|
changeOutputDevice={Service.changeOutputDevice}
|
|
|
|
joinEchoTest={Service.joinEchoTest}
|
|
|
|
exitAudio={Service.exitAudio}
|
|
|
|
showVolumeMeter={SHOW_VOLUME_METER}
|
|
|
|
localEchoEnabled={LOCAL_ECHO_TEST_ENABLED}
|
|
|
|
listenOnlyMode={listenOnlyMode}
|
|
|
|
formattedDialNum={formattedDialNum}
|
|
|
|
formattedTelVoice={formattedTelVoice}
|
|
|
|
combinedDialInNum={combinedDialInNum}
|
|
|
|
audioLocked={userLocks.userMic}
|
|
|
|
autoJoin={autoJoin}
|
|
|
|
skipCheck={skipCheck}
|
|
|
|
skipCheckOnJoin={skipCheckOnJoin}
|
|
|
|
isMobileNative={navigator.userAgent.toLowerCase().includes('bbbnative')}
|
|
|
|
isIE={isIe}
|
|
|
|
handleAllowAutoplay={Service.handleAllowAutoplay}
|
|
|
|
notify={Service.notify}
|
|
|
|
isRTL={isRTL}
|
|
|
|
AudioError={AudioError}
|
|
|
|
getTroubleshootingLink={AudioModalService.getTroubleshootingLink}
|
|
|
|
setIsOpen={setIsOpen}
|
2024-06-06 21:50:03 +08:00
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
2024-05-29 21:26:11 +08:00
|
|
|
};
|
2018-03-02 20:01:34 +08:00
|
|
|
|
2024-06-13 04:44:52 +08:00
|
|
|
export default AudioModalContainer;
|