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';
|
2016-05-20 21:37:19 +08:00
|
|
|
import App from './component';
|
2016-11-07 23:52:39 +08:00
|
|
|
import {
|
2017-03-10 03:50:21 +08:00
|
|
|
subscribeToCollections,
|
2016-11-07 23:52:39 +08:00
|
|
|
wasUserKicked,
|
|
|
|
redirectToLogoutUrl,
|
|
|
|
getModal,
|
2016-12-23 08:44:31 +08:00
|
|
|
getCaptionsStatus,
|
2017-03-10 03:50:21 +08:00
|
|
|
showModal,
|
2016-11-07 23:52:39 +08:00
|
|
|
} from './service';
|
|
|
|
|
2016-05-20 21:44:27 +08:00
|
|
|
import NavBarContainer from '../nav-bar/container';
|
2016-05-20 21:37:19 +08:00
|
|
|
import ActionsBarContainer from '../actions-bar/container';
|
2016-05-20 21:44:27 +08:00
|
|
|
import MediaContainer from '../media/container';
|
2016-07-23 08:12:31 +08:00
|
|
|
import ClosedCaptionsContainer from '../closed-captions/container';
|
2017-01-21 01:50:03 +08:00
|
|
|
import UserListService from '../user-list/service';
|
2017-03-10 03:50:21 +08:00
|
|
|
import AudioModalContainer from '/imports/ui/components/audio-modal/container';
|
|
|
|
|
2016-12-23 07:34:20 +08:00
|
|
|
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 />,
|
2016-12-23 08:44:31 +08:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|
2016-07-07 22:01:40 +08:00
|
|
|
};
|
|
|
|
|
2016-12-23 07:34:20 +08:00
|
|
|
const checkUnreadMessages = () => {
|
2017-01-21 01:50:03 +08:00
|
|
|
return UserListService.getOpenChats().map(chat=> chat.unreadCounter)
|
2017-01-14 07:57:29 +08:00
|
|
|
.filter(userID => userID !== Auth.userID);
|
2016-12-23 07:34:20 +08:00
|
|
|
};
|
|
|
|
|
2017-01-21 01:50:03 +08:00
|
|
|
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-01-21 01:50:03 +08:00
|
|
|
|
2017-03-10 03:50:21 +08:00
|
|
|
const init = () => {
|
|
|
|
if (APP_CONFIG.autoJoinAudio) {
|
|
|
|
showModal(<AudioModalContainer />);
|
|
|
|
}
|
|
|
|
};
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2017-03-10 03:50:21 +08:00
|
|
|
export default createContainer(({ params }) => ({
|
|
|
|
init,
|
|
|
|
wasKicked: wasUserKicked(),
|
|
|
|
modal: getModal(),
|
|
|
|
unreadMessageCount: checkUnreadMessages(),
|
|
|
|
openChats: openChats(params.chatID),
|
|
|
|
openChat: params.chatID,
|
|
|
|
getCaptionsStatus,
|
|
|
|
redirectToLogoutUrl,
|
|
|
|
}), AppContainer);
|
2016-07-08 19:59:05 +08:00
|
|
|
|
|
|
|
AppContainer.defaultProps = defaultProps;
|