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

85 lines
2.1 KiB
React
Raw Normal View History

2016-07-21 22:24:50 +08:00
import React, { Component, PropTypes, cloneElement } from 'react';
2016-04-29 03:02:51 +08:00
import { createContainer } from 'meteor/react-meteor-data';
import App from './component';
import {
subscribeForData,
wasUserKicked,
redirectToLogoutUrl,
getModal,
getCaptionsStatus,
} from './service';
import NavBarContainer from '../nav-bar/container';
import ActionsBarContainer from '../actions-bar/container';
import MediaContainer from '../media/container';
import ClosedCaptionsContainer from '../closed-captions/container';
import userListService from '../user-list/service';
import Auth from '/imports/ui/services/auth';
import ChatService from '../chat/service';
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id;
2016-04-29 03:02:51 +08:00
const defaultProps = {
2016-07-21 22:24:50 +08:00
navbar: <NavBarContainer />,
2016-07-23 02:47:54 +08:00
actionsbar: <ActionsBarContainer />,
2016-07-21 22:24:50 +08:00
media: <MediaContainer />,
//CCs UI is commented till the next pull request
captions: <ClosedCaptionsContainer />,
2016-04-29 03:02:51 +08:00
};
class AppContainer extends Component {
render() {
2016-07-21 22:24:50 +08:00
// inject location on the navbar container
let navbarWithLocation = cloneElement(this.props.navbar, { location: this.props.location });
2016-04-29 03:02:51 +08:00
return (
2016-07-21 22:24:50 +08:00
<App {...this.props} navbar={navbarWithLocation}>
2016-04-29 03:02:51 +08:00
{this.props.children}
</App>
);
}
}
let loading = true;
const loadingDep = new Tracker.Dependency;
const getLoading = () => {
2016-07-09 07:13:26 +08:00
loadingDep.depend();
return loading;
};
const setLoading = (val) => {
if (val !== loading) {
loading = val;
loadingDep.changed();
}
};
const checkUnreadMessages = () => {
let users = userListService.getUsers();
return users
.map(user => user.id)
.filter(userID => userID !== Auth.userID)
.concat(PUBLIC_CHAT_KEY)
.some(receiverID => ChatService.hasUnreadMessages(receiverID));
};
2016-04-29 03:02:51 +08:00
export default createContainer(() => {
Promise.all(subscribeForData())
.then(() => {
setLoading(false);
2016-07-29 03:48:26 +08:00
});
return {
2016-07-29 03:57:42 +08:00
wasKicked: wasUserKicked(),
isLoading: getLoading(),
modal: getModal(),
getCaptionsStatus,
2016-07-29 03:48:26 +08:00
redirectToLogoutUrl,
};
2016-04-29 03:02:51 +08:00
}, AppContainer);
AppContainer.defaultProps = defaultProps;