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

90 lines
3.4 KiB
React
Raw Normal View History

2017-09-29 21:38:10 +08:00
import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
2017-09-29 21:38:10 +08:00
import { withModalMounter } from '/imports/ui/components/modal/service';
import browser from 'browser-detect';
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';
import deviceInfo from '/imports/utils/deviceInfo';
2019-05-24 00:47:56 +08:00
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
2017-09-29 21:38:10 +08:00
import Service from '../service';
const AudioModalContainer = props => <AudioModal {...props} />;
const APP_CONFIG = Meteor.settings.public.app;
2018-03-06 04:00:52 +08:00
2019-05-24 00:47:56 +08:00
export default lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks }) => {
const listenOnlyMode = getFromUserSettings('listenOnlyMode', APP_CONFIG.listenOnlyMode);
const forceListenOnly = getFromUserSettings('forceListenOnly', APP_CONFIG.forceListenOnly);
const skipCheck = getFromUserSettings('skipCheck', APP_CONFIG.skipCheck);
2019-04-17 01:04:23 +08:00
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const invalidDialNumbers = ['0', '613-555-1212', '613-555-1234', '0000'];
2019-04-17 01:04:23 +08:00
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, '')}`;
}
}
return ({
closeModal: () => {
if (!Service.isConnecting()) mountModal(null);
},
2018-03-06 04:00:52 +08:00
joinMicrophone: () => {
const call = new Promise((resolve, reject) => {
if (skipCheck) {
resolve(Service.joinMicrophone());
} else {
resolve(Service.transferCall());
}
reject(() => {
Service.exitAudio();
});
});
return call.then(() => {
mountModal(null);
}).catch((error) => {
throw error;
2018-03-06 04:00:52 +08:00
});
},
joinListenOnly: () => Service.joinListenOnly().then(() => mountModal(null)),
leaveEchoTest: () => {
if (!Service.isEchoTest()) {
return Promise.resolve();
}
return Service.exitAudio();
},
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(),
2018-03-06 04:00:52 +08:00
listenOnlyMode,
skipCheck,
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,
2018-03-06 04:00:52 +08:00
joinFullAudioImmediately: !listenOnlyMode && skipCheck,
2018-03-06 22:36:49 +08:00
joinFullAudioEchoTest: !listenOnlyMode && !skipCheck,
2018-03-06 04:00:52 +08:00
forceListenOnlyAttendee: listenOnlyMode && forceListenOnly && !Service.isUserModerator(),
isIOSChrome: browser().name === 'crios',
isMobileNative: navigator.userAgent.toLowerCase().includes('bbbnative'),
2019-03-29 05:53:42 +08:00
isIEOrEdge: browser().name === 'edge' || browser().name === 'ie',
hasMediaDevices: deviceInfo.hasMediaDevices,
});
2019-05-24 00:47:56 +08:00
})(AudioModalContainer)));