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

78 lines
2.2 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 {
2017-03-10 03:50:21 +08:00
subscribeToCollections,
wasUserKicked,
redirectToLogoutUrl,
getModal,
getCaptionsStatus,
2017-03-10 03:50:21 +08:00
showModal,
getFontSize,
} from './service';
2017-03-09 22:34:33 +08:00
import { setDefaultSettings, getSettingsFor } from '/imports/ui/components/settings/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';
2017-03-10 03:50:21 +08:00
import AudioModalContainer from '/imports/ui/components/audio-modal/container';
import Auth from '/imports/ui/services/auth';
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 />,
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>
);
}
};
const checkUnreadMessages = () => {
return UserListService.getOpenChats().map(chat=> chat.unreadCounter)
.filter(userID => userID !== Auth.userID);
};
const openChats = (chatID) => {
// get currently opened chatID
return UserListService.getOpenChats(chatID).map(chat => chat.id);
2017-03-10 03:50:21 +08:00
};
const APP_CONFIG = Meteor.settings.public.app;
2017-03-10 03:50:21 +08:00
const init = () => {
if (APP_CONFIG.autoJoinAudio) {
showModal(<AudioModalContainer />);
}
};
2017-03-10 03:50:21 +08:00
export default createContainer(({ params }) => ({
init,
wasKicked: wasUserKicked(),
2017-03-14 01:19:43 +08:00
isLoading: getLoading(),
2017-03-10 03:50:21 +08:00
modal: getModal(),
unreadMessageCount: checkUnreadMessages(),
openChats: openChats(params.chatID),
openChat: params.chatID,
getCaptionsStatus,
redirectToLogoutUrl,
2017-03-14 01:19:43 +08:00
setDefaultSettings,
fontSize: getFontSize(),
applicationSettings: getSettingsFor('application'),
2017-03-10 03:50:21 +08:00
}), AppContainer);
AppContainer.defaultProps = defaultProps;