adjusted to meet component/container structure conventions and simplify code

This commit is contained in:
Matthew Marangoni 2016-11-18 13:24:59 -08:00
parent 0abcc06bfc
commit aa65afffa4
5 changed files with 30 additions and 35 deletions

View File

@ -5,7 +5,7 @@ import Users from '/imports/api/users/index';
import Auth from '/imports/ui/services/auth/index';
import MuteAudioContainer from '../mute-button/container';
export default class JoinAudioComponent extends React.Component {
export default class JoinAudio extends React.Component {
renderLeaveButton() {
return (
@ -13,7 +13,7 @@ export default class JoinAudioComponent extends React.Component {
<Button
onClick={this.props.close}
label={'Leave Audio'}
color={'primary'}
color={'danger'}
icon={'audio'}
size={'lg'}
circle={true}
@ -32,17 +32,17 @@ export default class JoinAudioComponent extends React.Component {
);
} else if (this.props.isInListenOnly) {
return this.renderLeaveButton();
} else {
return (
<Button
onClick={this.props.open}
label={'Join Audio'}
color={'primary'}
icon={'audio'}
size={'lg'}
circle={true}
/>
);
}
return (
<Button
onClick={this.props.open}
label={'Join Audio'}
color={'primary'}
icon={'audio'}
size={'lg'}
circle={true}
/>
);
}
}

View File

@ -3,23 +3,24 @@ import { createContainer } from 'meteor/react-meteor-data';
import Button from '/imports/ui/components/button/component';
import Users from '/imports/api/users/index';
import Auth from '/imports/ui/services/auth/index';
import JoinAudioComponent from './component';
import JoinAudio from './component';
class JoinAudioContainer extends React.Component {
render() {
return (
<JoinAudioComponent {...this.props} />
<JoinAudio {...this.props} />
);
}
}
export default createContainer((params) => {
const data = {
isInAudio: Users.findOne({ userId: Auth.userID }).user.voiceUser.joined,
isInListenOnly: Users.findOne({ userId: Auth.userID }).user.listenOnly,
const user = Users.findOne({ userId: Auth.userID }).user;
return {
isInAudio: user.voiceUser.joined,
isInListenOnly: user.listenOnly,
open: params.open,
close: params.close,
};
return data;
}, JoinAudioContainer);

View File

@ -10,7 +10,7 @@ import Users from '/imports/api/users/index';
import JoinAudioContainer from './audio-menu/container';
import { exitAudio } from '/imports/api/phone';
const openJoinAudio = () => {showModal(<Audio />);};
const openJoinAudio = () => showModal(<Audio />);
export default class ActionsBar extends Component {
constructor(props) {
@ -29,11 +29,8 @@ export default class ActionsBar extends Component {
<div className={styles.center}>
<JoinAudioContainer
open={openJoinAudio.bind(this)}
close={
() => {
exitAudio();
}
}
close={() => {exitAudio();}}
/>
<Button

View File

@ -6,21 +6,14 @@ import Users from '/imports/api/users/index';
import Auth from '/imports/ui/services/auth/index';
export default class MuteAudioComponent extends React.Component {
muteUser() {
callServer('muteUser', Auth.userID);
}
unmuteUser() {
callServer('unmuteUser', Auth.userID);
}
render() {
const { isMuted } = this.props;
let onClick = this.muteUser;
const { isMuted, muteUser, unmuteUser } = this.props;
let onClick = muteUser;
let label = 'Mute';
if (isMuted) {
onClick = this.unmuteUser;
onClick = unmuteUser;
label = 'Unmute';
}

View File

@ -11,6 +11,8 @@ class MuteAudioContainer extends React.Component {
return (
<MuteAudioComponent
isMuted = {this.props.isMuted}
muteUser = {this.props.muteUser}
unmuteUser = {this.props.unmuteUser}
/>
);
}
@ -19,6 +21,8 @@ class MuteAudioContainer extends React.Component {
export default createContainer((params) => {
const data = {
isMuted: Users.findOne({ userId: Auth.userID }).user.voiceUser.muted,
muteUser: () => callServer('muteUser', Auth.userID),
unmuteUser: () => callServer('unmuteUser', Auth.userID),
};
return data;
}, MuteAudioContainer);