bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/actions-bar/mute-button/container.jsx
2016-12-08 10:11:49 -08:00

39 lines
986 B
JavaScript
Executable File

import React from 'react';
import {createContainer} from 'meteor/react-meteor-data';
import {callServer} from '/imports/ui/services/api';
import Button from '/imports/ui/components/button/component';
import Users from '/imports/api/users/index';
import Auth from '/imports/ui/services/auth/index';
import MuteAudio from './component';
class MuteAudioContainer extends React.Component {
render() {
return (
<MuteAudio {...this.props} />
);
}
}
export default createContainer((params) => {
const userId = Auth.userID;
const user = Users.findOne({ userId: userId }).user;
const isMuted = user.voiceUser.muted;
const isInAudio = user.voiceUser.joined;
let callback = () => {};
if (isInAudio && !isMuted) {
callback = () => callServer('muteUser', userId);
}
if (isInAudio && isMuted) {
callback = () => callServer('unmuteUser', userId);
}
const data = {
isInAudio,
isMuted,
callback,
};
return data;
}, MuteAudioContainer);