bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/media/container.jsx

75 lines
1.9 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import Media from './component';
import MediaService from './service';
import PresentationPodsContainer from '../presentation-pod/container';
import VideoDockContainer from '../video-dock/container';
import ScreenshareContainer from '../screenshare/container';
2017-02-14 05:08:10 +08:00
import DefaultContent from '../presentation/default-content/component';
const defaultProps = {
2017-09-01 23:26:57 +08:00
overlay: <VideoDockContainer />,
content: <PresentationPodsContainer />,
defaultContent: <DefaultContent />,
};
2016-05-03 06:42:54 +08:00
class MediaContainer extends Component {
2016-04-29 03:02:51 +08:00
constructor(props) {
super(props);
const { overlay, content, defaultContent } = this.props;
this.state = {
2017-06-03 03:25:02 +08:00
overlay,
content: this.props.current_presentation ? content : defaultContent,
};
this.handleToggleLayout = this.handleToggleLayout.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.current_presentation !== this.props.current_presentation) {
if (nextProps.current_presentation) {
this.setState({ content: this.props.content });
} else {
this.setState({ content: this.props.defaultContent });
}
}
}
handleToggleLayout() {
const { overlay, content } = this.state;
this.setState({ overlay: content, content: overlay });
2016-04-29 03:02:51 +08:00
}
render() {
return (
2016-09-15 04:25:31 +08:00
<Media {...this.props}>
2016-04-29 03:02:51 +08:00
{this.props.children}
2016-05-03 06:42:54 +08:00
</Media>
2016-04-29 03:02:51 +08:00
);
}
}
MediaContainer.defaultProps = defaultProps;
export default withTracker(() => {
2017-06-03 03:25:02 +08:00
const data = {};
2016-09-15 04:25:31 +08:00
data.currentPresentation = MediaService.getPresentationInfo();
2017-03-22 05:46:41 +08:00
data.content = <DefaultContent />;
2016-09-15 04:25:31 +08:00
if (MediaService.shouldShowWhiteboard()) {
data.content = <PresentationPodsContainer />;
2016-09-15 04:25:31 +08:00
}
if (MediaService.shouldShowScreenshare()) {
data.content = <ScreenshareContainer />;
2016-09-15 04:25:31 +08:00
}
if (MediaService.shouldShowOverlay()) {
data.overlay = <VideoDockContainer />;
}
return data;
})(MediaContainer);