bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx
2021-03-30 09:53:47 -03:00

93 lines
3.9 KiB
JavaScript
Executable File

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { withModalMounter } from '/imports/ui/components/modal/service';
import Bowser from 'bowser';
import getFromUserSettings from '/imports/ui/services/users-settings';
import AudioModal from './component';
import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
import AudioError from '/imports/ui/services/audio-manager/error-codes';
import AppService from '/imports/ui/components/app/service';
import {
joinMicrophone,
closeModal,
joinListenOnly,
leaveEchoTest,
getcookieData,
} from './service';
import Storage from '/imports/ui/services/storage/session';
import Service from '../service';
const AudioModalContainer = props => <AudioModal {...props} />;
const APP_CONFIG = Meteor.settings.public.app;
const invalidDialNumbers = ['0', '613-555-1212', '613-555-1234', '0000'];
const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
export default lockContextContainer(withModalMounter(withTracker(({ userLocks }) => {
const listenOnlyMode = getFromUserSettings('bbb_listen_only_mode', APP_CONFIG.listenOnlyMode);
const forceListenOnly = getFromUserSettings('bbb_force_listen_only', APP_CONFIG.forceListenOnly);
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: { voiceProp: 1 } });
const getEchoTest = Storage.getItem('getEchoTest');
let formattedDialNum = '';
let formattedTelVoice = '';
let combinedDialInNum = '';
if (meeting && meeting.voiceProp) {
const { dialNumber, telVoice } = meeting.voiceProp;
if (invalidDialNumbers.indexOf(dialNumber) < 0) {
formattedDialNum = dialNumber;
formattedTelVoice = telVoice;
combinedDialInNum = `${dialNumber.replace(/\D+/g, '')},,,${telVoice.replace(/\D+/g, '')}`;
}
}
const meetingIsBreakout = AppService.meetingIsBreakout();
const { joinedAudio } = getcookieData();
const joinFullAudioImmediately = (autoJoin && (skipCheck || skipCheckOnJoin && !getEchoTest))
|| (skipCheck || skipCheckOnJoin && !getEchoTest);
const forceListenOnlyAttendee = forceListenOnly && !Service.isUserModerator();
const BROWSER_RESULTS = Bowser.parse(window.navigator.userAgent);
return ({
joinedAudio,
meetingIsBreakout,
closeModal,
joinMicrophone: skipEchoTest => joinMicrophone(skipEchoTest || skipCheck || skipCheckOnJoin),
joinListenOnly,
leaveEchoTest,
changeInputDevice: inputDeviceId => Service.changeInputDevice(inputDeviceId),
changeOutputDevice: outputDeviceId => Service.changeOutputDevice(outputDeviceId),
joinEchoTest: () => Service.joinEchoTest(),
exitAudio: () => Service.exitAudio(),
isConnecting: Service.isConnecting(),
isConnected: Service.isConnected(),
isEchoTest: Service.isEchoTest(),
inputDeviceId: Service.inputDeviceId(),
outputDeviceId: Service.outputDeviceId(),
showPermissionsOvelay: Service.isWaitingPermissions(),
listenOnlyMode,
formattedDialNum,
formattedTelVoice,
combinedDialInNum,
audioLocked: userLocks.userMic,
joinFullAudioImmediately,
forceListenOnlyAttendee,
isIOSChrome: BROWSER_RESULTS.os.name.includes('iOS') && BROWSER_RESULTS.browser.name === 'Chrome',
isMobileNative: navigator.userAgent.toLowerCase().includes('bbbnative'),
isIEOrEdge: BROWSER_RESULTS.browser.name === 'Microsoft Edge' || BROWSER_RESULTS.browser.name === 'Internet Explorer',
autoplayBlocked: Service.autoplayBlocked(),
handleAllowAutoplay: () => Service.handleAllowAutoplay(),
isRTL,
AudioError,
});
})(AudioModalContainer)));