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';
|
2017-03-17 22:38:18 +08:00
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
import {
|
|
|
|
getModal,
|
2017-02-25 04:19:53 +08:00
|
|
|
getFontSize,
|
2017-03-17 03:57:45 +08:00
|
|
|
getCaptionsStatus,
|
2016-11-07 23:52:39 +08:00
|
|
|
} from './service';
|
|
|
|
|
2017-03-17 22:23:00 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
|
2017-03-17 03:57:45 +08:00
|
|
|
import App from './component';
|
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';
|
2017-04-26 01:04:17 +08:00
|
|
|
import AudioModalContainer from '../audio-modal/container';
|
2017-03-24 00:19:02 +08:00
|
|
|
import ClosedCaptionsContainer from '/imports/ui/components/closed-captions/container';
|
2016-12-23 07:34:20 +08:00
|
|
|
|
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-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
2017-03-17 22:38:18 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
kickedMessage: {
|
|
|
|
id: 'app.error.kicked',
|
|
|
|
description: 'Message when the user is kicked out of the meeting',
|
|
|
|
defaultMessage: 'You have been kicked out of the meeting',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2017-03-10 03:50:21 +08:00
|
|
|
const init = () => {
|
2017-04-19 22:59:57 +08:00
|
|
|
// TODO
|
2017-03-10 03:50:21 +08:00
|
|
|
};
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2017-03-17 22:38:18 +08:00
|
|
|
export default withRouter(injectIntl(createContainer(({ router, intl, baseControls }) => {
|
2017-03-17 22:23:00 +08:00
|
|
|
// Check if user is kicked out of the session
|
|
|
|
Users.find({ userId: Auth.userID }).observeChanges({
|
2017-04-26 01:04:17 +08:00
|
|
|
changed(id, fields) {
|
|
|
|
if (fields.user) {
|
|
|
|
if (fields.user.kicked) {
|
|
|
|
Auth.clearCredentials()
|
|
|
|
.then(() => {
|
|
|
|
router.push('/error/403');
|
|
|
|
baseControls.updateErrorState(
|
|
|
|
intl.formatMessage(intlMessages.kickedMessage),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2017-03-17 22:23:00 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Close the widow when the current breakout room ends
|
|
|
|
Breakouts.find({ breakoutMeetingId: Auth.meetingID }).observeChanges({
|
|
|
|
removed(old) {
|
|
|
|
Auth.clearCredentials().then(window.close);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
init,
|
|
|
|
sidebar: getCaptionsStatus() ? <ClosedCaptionsContainer /> : null,
|
|
|
|
modal: getModal(),
|
|
|
|
fontSize: getFontSize(),
|
|
|
|
};
|
2017-03-17 22:38:18 +08:00
|
|
|
}, AppContainer)));
|
2016-07-08 19:59:05 +08:00
|
|
|
|
|
|
|
AppContainer.defaultProps = defaultProps;
|