Merge pull request #5242 from Tainan404/test-screenshare

Stop screen share when switch presenter.
This commit is contained in:
Anton Georgiev 2018-03-16 10:40:26 -04:00 committed by GitHub
commit 75ad4d309c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 11 deletions

View File

@ -4,6 +4,14 @@ export default class ScreenshareComponent extends React.Component {
componentDidMount() {
this.props.presenterScreenshareHasStarted();
}
componentWillReceiveProps(nextProps) {
if (this.props.isPresenter && !nextProps.isPresenter) {
this.props.unshareScreen();
}
}
componentWillUnmount() {
this.props.presenterScreenshareHasEnded();
}
render() {
return (

View File

@ -1,14 +1,13 @@
import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { isVideoBroadcasting, presenterScreenshareHasEnded,
import Users from '/imports/api/users/';
import Auth from '/imports/ui/services/auth';
import mapUser from '/imports/ui/services/user/mapUser';
import { isVideoBroadcasting, presenterScreenshareHasEnded, unshareScreen,
presenterScreenshareHasStarted } from './service';
import ScreenshareComponent from './component';
class ScreenshareContainer extends React.Component {
componentWillUnmount() {
this.props.presenterScreenshareHasEnded();
}
render() {
if (this.props.isVideoBroadcasting()) {
return <ScreenshareComponent {...this.props} />;
@ -18,9 +17,14 @@ class ScreenshareContainer extends React.Component {
}
}
export default withTracker(() => ({
isVideoBroadcasting,
presenterScreenshareHasStarted,
presenterScreenshareHasEnded,
}))(ScreenshareContainer);
export default withTracker(() => {
const user = Users.findOne({ userId: Auth.userID });
const MappedUser = mapUser(user);
return {
isPresenter: MappedUser.isPresenter,
unshareScreen,
isVideoBroadcasting,
presenterScreenshareHasStarted,
presenterScreenshareHasEnded,
};
})(ScreenshareContainer);