bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx
Ramón Souza 7514066fc3
fix: Client can't load in certain cases (#20336)
* move settings

* remove meteor cache files
2024-05-29 09:26:11 -04:00

123 lines
4.7 KiB
JavaScript
Executable File

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import browserInfo from '/imports/utils/browserInfo';
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,
} from './service';
import Storage from '/imports/ui/services/storage/session';
import Service from '../service';
import AudioModalService from '/imports/ui/components/audio/audio-modal/service';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
const AudioModalContainer = (props) => {
const { data: currentUserData } = useCurrentUser((user) => ({
away: user.away,
isModerator: user.isModerator,
}));
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;
return <AudioModal away={away} forceListenOnlyAttendee={forceListenOnlyAttendee} {...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 } });
const getEchoTest = Storage.getItem('getEchoTest');
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 meetingIsBreakout = AppService.meetingIsBreakout();
const joinFullAudioImmediately = (
autoJoin
&& (
skipCheck
|| (skipCheckOnJoin && !getEchoTest)
))
|| (
skipCheck
|| (skipCheckOnJoin && !getEchoTest)
);
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(),
isConnecting: Service.isConnecting(),
isConnected: Service.isConnected(),
isUsingAudio: Service.isUsingAudio(),
isEchoTest: Service.isEchoTest(),
inputDeviceId: Service.inputDeviceId(),
outputDeviceId: Service.outputDeviceId(),
showPermissionsOvelay: Service.isWaitingPermissions(),
showVolumeMeter: SHOW_VOLUME_METER,
localEchoEnabled: LOCAL_ECHO_TEST_ENABLED,
listenOnlyMode,
formattedDialNum,
formattedTelVoice,
combinedDialInNum,
audioLocked: userLocks.userMic,
joinFullAudioImmediately,
isMobileNative: navigator.userAgent.toLowerCase().includes('bbbnative'),
isIE: isIe,
autoplayBlocked: Service.autoplayBlocked(),
handleAllowAutoplay: () => Service.handleAllowAutoplay(),
notify: Service.notify,
isRTL,
AudioError,
getTroubleshootingLink: AudioModalService.getTroubleshootingLink,
isListenOnly: Service.isListenOnly(),
});
})(AudioModalContainer));