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

103 lines
2.9 KiB
React
Raw Normal View History

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
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';
import Users from '/imports/api/users';
import Meetings from '/imports/api/meetings';
2017-07-14 22:18:07 +08:00
import ClosedCaptionsContainer from '/imports/ui/components/closed-captions/container';
import getFromUserSettings from '/imports/ui/services/users-settings';
2017-07-14 22:18:07 +08:00
import {
getFontSize,
getCaptionsStatus,
2018-10-24 01:18:09 +08:00
getBreakoutRooms,
} from './service';
2017-04-19 03:06:51 +08:00
import { withModalMounter } from '../modal/service';
import App from './component';
import NavBarContainer from '../nav-bar/container';
import ActionsBarContainer from '../actions-bar/container';
import MediaContainer from '../media/container';
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
};
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',
},
});
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
navbar={navbar}
2017-10-06 22:58:21 +08:00
actionsbar={actionsbar}
media={media}
{...otherProps}
/>
2017-07-14 22:18:07 +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 });
2018-11-20 04:55:09 +08:00
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
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
// 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);
if (fields.ejected || hasNewConnection) {
2018-10-25 23:20:37 +08:00
endMeeting('403');
2017-06-03 03:25:02 +08:00
}
},
});
2019-03-20 04:06:13 +08:00
if (meeting && meeting.meetingEnded) window.close();
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,
customStyle: getFromUserSettings('customStyle', false),
customStyleUrl: getFromUserSettings('customStyleUrl', false),
breakoutRoomIsOpen: Session.equals('openPanel', 'breakoutroom'),
chatIsOpen: Session.equals('openPanel', 'chat'),
openPanel: Session.get('openPanel'),
userListIsOpen: !Session.equals('openPanel', ''),
2017-06-03 03:25:02 +08:00
};
2018-10-03 03:53:13 +08:00
})(AppContainer)));
AppContainer.defaultProps = defaultProps;
2017-10-06 22:58:21 +08:00
AppContainer.propTypes = propTypes;