2018-10-12 04:41:37 +08:00
|
|
|
import React from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2017-03-17 22:38:18 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-10-06 22:58:21 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-07-14 22:18:07 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
2018-08-15 01:29:03 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2017-07-14 22:18:07 +08:00
|
|
|
|
|
|
|
import ClosedCaptionsContainer from '/imports/ui/components/closed-captions/container';
|
2018-10-19 04:37:14 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2017-07-14 22:18:07 +08:00
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
import {
|
2017-02-25 04:19:53 +08:00
|
|
|
getFontSize,
|
2017-03-17 03:57:45 +08:00
|
|
|
getCaptionsStatus,
|
2017-10-06 22:58:21 +08:00
|
|
|
meetingIsBreakout,
|
2018-10-24 01:18:09 +08:00
|
|
|
getBreakoutRooms,
|
2016-11-07 23:52:39 +08:00
|
|
|
} from './service';
|
|
|
|
|
2017-04-19 03:06:51 +08:00
|
|
|
import { withModalMounter } from '../modal/service';
|
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';
|
2016-12-23 07:34:20 +08:00
|
|
|
|
2017-10-06 22:58:21 +08:00
|
|
|
const propTypes = {
|
|
|
|
navbar: PropTypes.node,
|
|
|
|
actionsbar: PropTypes.node,
|
|
|
|
media: PropTypes.node,
|
|
|
|
};
|
|
|
|
|
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({
|
2017-07-14 22:18:07 +08:00
|
|
|
waitingApprovalMessage: {
|
|
|
|
id: 'app.guest.waiting',
|
|
|
|
description: 'Message while a guest is waiting to be approved',
|
|
|
|
},
|
2017-03-17 22:38:18 +08:00
|
|
|
});
|
|
|
|
|
2018-10-25 23:20:37 +08:00
|
|
|
const endMeeting = (code) => {
|
|
|
|
Session.set('codeError', code);
|
|
|
|
Session.set('isMeetingEnded', true);
|
|
|
|
};
|
|
|
|
|
2017-07-14 22:18:07 +08:00
|
|
|
const AppContainer = (props) => {
|
2017-10-06 22:58:21 +08:00
|
|
|
const {
|
|
|
|
navbar,
|
|
|
|
actionsbar,
|
|
|
|
media,
|
|
|
|
...otherProps
|
|
|
|
} = props;
|
|
|
|
|
2017-07-14 22:18:07 +08:00
|
|
|
return (
|
2017-10-06 22:58:21 +08:00
|
|
|
<App
|
2018-10-12 04:41:37 +08:00
|
|
|
navbar={navbar}
|
2017-10-06 22:58:21 +08:00
|
|
|
actionsbar={actionsbar}
|
|
|
|
media={media}
|
|
|
|
{...otherProps}
|
2017-10-12 03:11:04 +08:00
|
|
|
/>
|
2017-07-14 22:18:07 +08:00
|
|
|
);
|
|
|
|
};
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2018-01-11 19:19:56 +08:00
|
|
|
|
2018-10-03 03:53:13 +08:00
|
|
|
export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) => {
|
2017-07-14 22:18:07 +08:00
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
2017-10-27 21:44:42 +08:00
|
|
|
const isMeetingBreakout = meetingIsBreakout();
|
2017-07-14 22:18:07 +08:00
|
|
|
|
2018-07-19 20:46:44 +08:00
|
|
|
if (!currentUser.approved) {
|
|
|
|
baseControls.updateLoadingState(intl.formatMessage(intlMessages.waitingApprovalMessage));
|
|
|
|
}
|
2017-07-18 00:38:18 +08:00
|
|
|
|
2018-08-15 01:29:03 +08:00
|
|
|
logger.info('User joined meeting and subscribed to data successfully');
|
|
|
|
|
2018-01-10 06:28:48 +08:00
|
|
|
// Check if user is removed out of the session
|
2017-06-03 03:25:02 +08:00
|
|
|
Users.find({ userId: Auth.userID }).observeChanges({
|
|
|
|
changed(id, fields) {
|
2018-02-21 01:41:02 +08:00
|
|
|
const hasNewConnection = 'connectionId' in fields && (fields.connectionId !== Meteor.connection._lastSessionId);
|
2018-02-20 22:21:51 +08:00
|
|
|
|
|
|
|
if (fields.ejected || hasNewConnection) {
|
2018-10-25 23:20:37 +08:00
|
|
|
endMeeting('403');
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2017-01-21 01:50:03 +08:00
|
|
|
|
2018-06-11 23:55:09 +08:00
|
|
|
// forcefully log out when the meeting ends
|
2017-07-06 06:56:13 +08:00
|
|
|
Meetings.find({ meetingId: Auth.meetingID }).observeChanges({
|
2017-07-18 00:38:18 +08:00
|
|
|
removed() {
|
2018-06-11 23:55:09 +08:00
|
|
|
if (isMeetingBreakout) {
|
|
|
|
Auth.clearCredentials().then(window.close);
|
|
|
|
} else {
|
2018-10-25 23:20:37 +08:00
|
|
|
endMeeting('410');
|
2018-06-11 23:55:09 +08:00
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
},
|
|
|
|
});
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2018-06-11 23:55:09 +08:00
|
|
|
// Close the window when the current breakout room ends
|
2017-08-12 04:17:35 +08:00
|
|
|
Breakouts.find({ breakoutId: Auth.meetingID }).observeChanges({
|
2017-07-14 22:18:07 +08:00
|
|
|
removed() {
|
2017-06-03 03:25:02 +08:00
|
|
|
Auth.clearCredentials().then(window.close);
|
|
|
|
},
|
|
|
|
});
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
return {
|
|
|
|
closedCaption: getCaptionsStatus() ? <ClosedCaptionsContainer /> : null,
|
|
|
|
fontSize: getFontSize(),
|
2018-10-24 01:18:09 +08:00
|
|
|
hasBreakoutRooms: getBreakoutRooms().length > 0,
|
2018-10-25 23:20:37 +08:00
|
|
|
userListIsOpen: Session.get('isUserListOpen'),
|
2018-10-26 22:52:54 +08:00
|
|
|
breakoutRoomIsOpen: Session.get('breakoutRoomIsOpen') && Session.get('isUserListOpen'),
|
2018-10-25 23:20:37 +08:00
|
|
|
chatIsOpen: Session.get('isChatOpen') && Session.get('isUserListOpen'),
|
2018-10-19 04:37:14 +08:00
|
|
|
customStyle: getFromUserSettings('customStyle', false),
|
|
|
|
customStyleUrl: getFromUserSettings('customStyleUrl', false),
|
2017-06-03 03:25:02 +08:00
|
|
|
};
|
2018-10-03 03:53:13 +08:00
|
|
|
})(AppContainer)));
|
2016-07-08 19:59:05 +08:00
|
|
|
|
|
|
|
AppContainer.defaultProps = defaultProps;
|
2017-10-06 22:58:21 +08:00
|
|
|
AppContainer.propTypes = propTypes;
|