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

55 lines
2.2 KiB
React
Raw Normal View History

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { withModalMounter } from '/imports/ui/components/modal/service';
import AudioManager from '/imports/ui/services/audio-manager';
import { makeCall } from '/imports/ui/services/api';
import Users from '/imports/api/users/';
import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import AudioControls from './component';
2017-09-29 21:38:10 +08:00
import AudioModalContainer from '../audio-modal/container';
import Service from '../service';
const AudioControlsContainer = props => <AudioControls {...props} />;
const processToggleMuteFromOutside = (e) => {
switch (e.data) {
case 'c_mute': {
makeCall('toggleSelfVoice');
break;
}
case 'get_audio_joined_status': {
const audioJoinedState = AudioManager.isConnected ? 'joinedAudio' : 'notInAudio';
this.window.parent.postMessage({ response: audioJoinedState }, '*');
break;
}
case 'c_mute_status': {
const muteState = AudioManager.isMuted ? 'selfMuted' : 'selfUnmuted';
this.window.parent.postMessage({ response: muteState }, '*');
break;
}
default: {
// console.log(e.data);
}
}
};
export default withModalMounter(withTracker(({ mountModal }) =>
({
processToggleMuteFromOutside: arg => processToggleMuteFromOutside(arg),
mute: Service.isConnected() && !Service.isListenOnly() && !Service.isEchoTest(),
unmute: Service.isConnected() && !Service.isListenOnly() && Service.isMuted(),
join: Service.isConnected() && !Service.isEchoTest(),
disable: Service.isConnecting() || Service.isHangingUp(),
glow: Service.isTalking() && !Service.isMuted(),
handleToggleMuteMicrophone: () => Service.toggleMuteMicrophone(),
handleJoinAudio: () => {
2018-11-20 02:59:47 +08:00
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const currentUser = Users.findOne({ userId: Auth.userID });
2018-11-21 20:59:30 +08:00
const micsLocked = (currentUser.locked && meeting.lockSettingsProp.disableMic);
2018-11-20 02:59:47 +08:00
return micsLocked ? Service.joinListenOnly() : mountModal(<AudioModalContainer />);
},
handleLeaveAudio: () => Service.exitAudio(),
}))(AudioControlsContainer));