2016-11-16 05:00:28 +08:00
|
|
|
import React from 'react';
|
2017-04-29 04:01:02 +08:00
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2016-11-16 05:00:28 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import Users from '/imports/api/users/index';
|
|
|
|
import Auth from '/imports/ui/services/auth/index';
|
2016-12-09 02:11:49 +08:00
|
|
|
import MuteAudio from './component';
|
2016-11-16 05:00:28 +08:00
|
|
|
|
|
|
|
class MuteAudioContainer extends React.Component {
|
|
|
|
render() {
|
|
|
|
return (
|
2016-12-09 02:11:49 +08:00
|
|
|
<MuteAudio {...this.props} />
|
2016-11-16 05:00:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default createContainer((params) => {
|
2016-12-07 05:15:23 +08:00
|
|
|
const userId = Auth.userID;
|
2017-06-03 03:25:02 +08:00
|
|
|
const user = Users.findOne({ userId }).user;
|
2016-12-09 02:11:49 +08:00
|
|
|
const isMuted = user.voiceUser.muted;
|
|
|
|
const isInAudio = user.voiceUser.joined;
|
2017-01-28 00:57:14 +08:00
|
|
|
const isTalking = user.voiceUser.talking;
|
2017-02-03 00:46:49 +08:00
|
|
|
|
2017-04-29 04:01:02 +08:00
|
|
|
let callback = () => { };
|
2016-12-09 02:11:49 +08:00
|
|
|
|
|
|
|
if (isInAudio && !isMuted) {
|
2017-04-26 21:47:44 +08:00
|
|
|
callback = () => makeCall('muteUser', userId);
|
2016-12-09 02:11:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isInAudio && isMuted) {
|
2017-04-26 21:47:44 +08:00
|
|
|
callback = () => makeCall('unmuteUser', userId);
|
2016-12-09 02:11:49 +08:00
|
|
|
}
|
|
|
|
|
2016-11-16 05:00:28 +08:00
|
|
|
const data = {
|
2016-12-09 02:11:49 +08:00
|
|
|
isInAudio,
|
|
|
|
isMuted,
|
|
|
|
callback,
|
2017-01-28 00:57:14 +08:00
|
|
|
isTalking,
|
2016-11-16 05:00:28 +08:00
|
|
|
};
|
|
|
|
return data;
|
|
|
|
}, MuteAudioContainer);
|