bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx

145 lines
5.6 KiB
React
Raw Normal View History

2017-09-29 21:38:10 +08:00
import React from 'react';
import { useReactiveVar } from '@apollo/client';
import { withTracker } from 'meteor/react-meteor-data';
import browserInfo from '/imports/utils/browserInfo';
import getFromUserSettings from '/imports/ui/services/users-settings';
2017-09-29 21:38:10 +08:00
import AudioModal from './component';
import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
2019-05-24 00:47:56 +08:00
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
2019-09-30 22:54:34 +08:00
import AudioError from '/imports/ui/services/audio-manager/error-codes';
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';
import AudioModalService from '/imports/ui/components/audio/audio-modal/service';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import AudioManager from '/imports/ui/services/audio-manager';
import { useStorageKey } from '/imports/ui/services/storage/hooks';
2017-09-29 21:38:10 +08:00
const AudioModalContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
away: user.away,
isModerator: user.isModerator,
}));
const getEchoTest = useStorageKey('getEchoTest', 'session');
const away = currentUserData?.away;
const isModerator = currentUserData?.isModerator;
const APP_CONFIG = window.meetingClientSettings.public.app;
const forceListenOnly = getFromUserSettings('bbb_force_listen_only', APP_CONFIG.forceListenOnly);
const forceListenOnlyAttendee = forceListenOnly && !isModerator;
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);
const { autoJoin, skipCheck, skipCheckOnJoin } = props;
const joinFullAudioImmediately = (
autoJoin
&& (
skipCheck
|| (skipCheckOnJoin && !getEchoTest)
))
|| (
skipCheck
|| (skipCheckOnJoin && !getEchoTest)
);
return (
<AudioModal
away={away}
forceListenOnlyAttendee={forceListenOnlyAttendee}
inputDeviceId={inputDeviceId}
outputDeviceId={outputDeviceId}
showPermissionsOvelay={showPermissionsOvelay}
isUsingAudio={isUsingAudio}
isConnecting={isConnecting}
isConnected={isConnected}
isListenOnly={isListenOnly}
isEchoTest={isEchoTest}
autoplayBlocked={autoplayBlocked}
getEchoTest={getEchoTest}
joinFullAudioImmediately={joinFullAudioImmediately}
{...props}
/>
);
};
const invalidDialNumbers = ['0', '613-555-1212', '613-555-1234', '0000'];
const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
export default lockContextContainer(withTracker(({ userLocks, setIsOpen }) => {
const APP_CONFIG = window.meetingClientSettings.public.app;
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);
const autoJoin = getFromUserSettings('bbb_auto_join_audio', APP_CONFIG.autoJoin);
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, { fields: { voiceSettings: 1 } });
2019-04-17 01:04:23 +08:00
let formattedDialNum = '';
let formattedTelVoice = '';
let combinedDialInNum = '';
if (meeting && meeting.voiceSettings) {
const { dialNumber, telVoice } = meeting.voiceSettings;
2019-04-17 01:04:23 +08:00
if (invalidDialNumbers.indexOf(dialNumber) < 0) {
formattedDialNum = dialNumber;
formattedTelVoice = telVoice;
combinedDialInNum = `${dialNumber.replace(/\D+/g, '')},,,${telVoice.replace(/\D+/g, '')}`;
}
}
const meetingIsBreakout = AppService.meetingIsBreakout();
2021-02-11 21:23:38 +08:00
const { isIe } = browserInfo;
const SHOW_VOLUME_METER = window.meetingClientSettings.public.media.showVolumeMeter;
const {
enabled: LOCAL_ECHO_TEST_ENABLED,
} = window.meetingClientSettings.public.media.localEchoTest;
return ({
meetingIsBreakout,
closeModal: () => closeModal(() => setIsOpen(false)),
joinMicrophone: (skipEchoTest) => joinMicrophone(skipEchoTest || skipCheck || skipCheckOnJoin),
joinListenOnly,
leaveEchoTest,
changeInputDevice: (inputDeviceId) => Service
.changeInputDevice(inputDeviceId),
changeInputStream: (inputStream) => Service.changeInputStream(inputStream),
changeOutputDevice: (outputDeviceId, isLive) => Service
.changeOutputDevice(outputDeviceId, isLive),
joinEchoTest: () => Service.joinEchoTest(),
exitAudio: () => Service.exitAudio(),
showVolumeMeter: SHOW_VOLUME_METER,
localEchoEnabled: LOCAL_ECHO_TEST_ENABLED,
2018-03-06 04:00:52 +08:00
listenOnlyMode,
2019-04-16 00:39:36 +08:00
formattedDialNum,
2019-04-17 01:04:23 +08:00
formattedTelVoice,
combinedDialInNum,
2019-05-24 00:47:56 +08:00
audioLocked: userLocks.userMic,
autoJoin,
skipCheck,
skipCheckOnJoin,
isMobileNative: navigator.userAgent.toLowerCase().includes('bbbnative'),
isIE: isIe,
handleAllowAutoplay: () => Service.handleAllowAutoplay(),
notify: Service.notify,
2019-08-27 04:47:54 +08:00
isRTL,
2019-09-30 22:54:34 +08:00
AudioError,
getTroubleshootingLink: AudioModalService.getTroubleshootingLink,
});
})(AudioModalContainer));