2021-05-18 04:25:07 +08:00
|
|
|
import React, { useContext } 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';
|
2020-09-16 20:52:44 +08:00
|
|
|
import AuthTokenValidation from '/imports/api/auth-token-validation';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2019-05-22 22:44:17 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2019-04-13 14:06:50 +08:00
|
|
|
import { notify } from '/imports/ui/services/notification';
|
2019-05-17 04:11:10 +08:00
|
|
|
import CaptionsContainer from '/imports/ui/components/captions/container';
|
|
|
|
import CaptionsService from '/imports/ui/components/captions/service';
|
2018-10-19 04:37:14 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2019-05-09 01:52:12 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2019-04-11 03:40:40 +08:00
|
|
|
import UserInfos from '/imports/api/users-infos';
|
2019-06-13 23:02:02 +08:00
|
|
|
import { startBandwidthMonitoring, updateNavigatorConnection } from '/imports/ui/services/network-information/index';
|
2021-05-18 04:25:07 +08:00
|
|
|
import { NLayoutContext } from '../layout/context/context';
|
2019-04-11 03:40:40 +08:00
|
|
|
|
2016-11-07 23:52:39 +08:00
|
|
|
import {
|
2017-02-25 04:19:53 +08:00
|
|
|
getFontSize,
|
2018-10-24 01:18:09 +08:00
|
|
|
getBreakoutRooms,
|
2019-04-19 01:14:34 +08:00
|
|
|
validIOSVersion,
|
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: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 = {
|
|
|
|
actionsbar: PropTypes.node,
|
|
|
|
media: PropTypes.node,
|
|
|
|
};
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
const defaultProps = {
|
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) => {
|
2021-05-18 04:25:07 +08:00
|
|
|
const newLayoutContext = useContext(NLayoutContext);
|
|
|
|
const { newLayoutContextState, newLayoutContextDispatch } = newLayoutContext;
|
|
|
|
|
2017-10-06 22:58:21 +08:00
|
|
|
const {
|
|
|
|
actionsbar,
|
|
|
|
media,
|
|
|
|
...otherProps
|
|
|
|
} = props;
|
2021-05-18 04:25:07 +08:00
|
|
|
const {
|
|
|
|
input,
|
|
|
|
layoutType,
|
|
|
|
deviceType,
|
|
|
|
} = newLayoutContextState;
|
2021-05-19 22:51:31 +08:00
|
|
|
const { sidebarContent, sidebarNavigation } = input;
|
|
|
|
const { sidebarNavPanel } = sidebarNavigation;
|
|
|
|
const { sidebarContentPanel } = sidebarContent;
|
2021-05-18 04:25:07 +08:00
|
|
|
const sidebarNavigationIsOpen = sidebarNavigation.isOpen;
|
|
|
|
const sidebarContentIsOpen = sidebarContent.isOpen;
|
2017-10-06 22:58:21 +08:00
|
|
|
|
2017-07-14 22:18:07 +08:00
|
|
|
return (
|
2017-10-06 22:58:21 +08:00
|
|
|
<App
|
2021-05-18 04:25:07 +08:00
|
|
|
{...{
|
|
|
|
actionsbar,
|
|
|
|
media,
|
|
|
|
layoutType,
|
|
|
|
deviceType,
|
|
|
|
newLayoutContextDispatch,
|
|
|
|
sidebarNavPanel,
|
|
|
|
sidebarNavigationIsOpen,
|
|
|
|
sidebarContentPanel,
|
|
|
|
sidebarContentIsOpen,
|
|
|
|
}}
|
2017-10-06 22:58:21 +08:00
|
|
|
{...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
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const currentUserEmoji = (currentUser) => (currentUser
|
|
|
|
? {
|
|
|
|
status: currentUser.emoji,
|
|
|
|
changedAt: currentUser.emojiTime,
|
|
|
|
}
|
|
|
|
: {
|
2020-10-08 03:50:17 +08:00
|
|
|
status: 'none',
|
|
|
|
changedAt: null,
|
2021-05-18 04:25:07 +08:00
|
|
|
}
|
|
|
|
);
|
2019-08-31 02:43:48 +08:00
|
|
|
|
2018-10-03 03:53:13 +08:00
|
|
|
export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) => {
|
2020-09-16 20:52:44 +08:00
|
|
|
const authTokenValidation = AuthTokenValidation.findOne({}, { sort: { updatedAt: -1 } });
|
|
|
|
|
|
|
|
if (authTokenValidation.connectionId !== Meteor.connection._lastSessionId) {
|
|
|
|
endMeeting('403');
|
|
|
|
}
|
|
|
|
|
2021-02-21 12:07:25 +08:00
|
|
|
Users.find({ userId: Auth.userID, meetingId: Auth.meetingID }).observe({
|
2020-09-16 20:52:44 +08:00
|
|
|
removed() {
|
|
|
|
endMeeting('403');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const currentUser = Users.findOne(
|
|
|
|
{ userId: Auth.userID },
|
|
|
|
{
|
|
|
|
fields:
|
|
|
|
{
|
|
|
|
approved: 1, emoji: 1, userId: 1, presenter: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2019-08-22 20:05:06 +08:00
|
|
|
const currentMeeting = Meetings.findOne({ meetingId: Auth.meetingID },
|
2020-08-29 01:23:27 +08:00
|
|
|
{ fields: { publishedPoll: 1, voiceProp: 1, randomlySelectedUser: 1 } });
|
|
|
|
const { publishedPoll, voiceProp, randomlySelectedUser } = currentMeeting;
|
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
|
|
|
|
2019-04-12 04:54:15 +08:00
|
|
|
const UserInfo = UserInfos.find({
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
requesterUserId: Auth.userID,
|
|
|
|
}).fetch();
|
2019-04-12 04:23:18 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const layoutManagerLoaded = Session.get('layoutManagerLoaded');
|
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
return {
|
2019-05-18 04:02:28 +08:00
|
|
|
captions: CaptionsService.isCaptionsActive() ? <CaptionsContainer /> : null,
|
2017-06-03 03:25:02 +08:00
|
|
|
fontSize: getFontSize(),
|
2018-10-24 01:18:09 +08:00
|
|
|
hasBreakoutRooms: getBreakoutRooms().length > 0,
|
2019-07-22 22:28:13 +08:00
|
|
|
customStyle: getFromUserSettings('bbb_custom_style', false),
|
2019-07-25 01:04:46 +08:00
|
|
|
customStyleUrl: getFromUserSettings('bbb_custom_style_url', false),
|
2019-04-11 03:40:40 +08:00
|
|
|
UserInfo,
|
2019-04-13 14:06:50 +08:00
|
|
|
notify,
|
2019-04-19 01:14:34 +08:00
|
|
|
validIOSVersion,
|
2021-04-01 01:13:36 +08:00
|
|
|
isPhone: deviceInfo.isPhone,
|
2019-07-16 03:15:58 +08:00
|
|
|
isRTL: document.documentElement.getAttribute('dir') === 'rtl',
|
2019-06-01 02:36:52 +08:00
|
|
|
meetingMuted: voiceProp.muteOnStart,
|
2019-08-31 02:43:48 +08:00
|
|
|
currentUserEmoji: currentUserEmoji(currentUser),
|
2019-06-01 02:36:52 +08:00
|
|
|
hasPublishedPoll: publishedPoll,
|
2019-06-13 23:02:02 +08:00
|
|
|
startBandwidthMonitoring,
|
|
|
|
handleNetworkConnection: () => updateNavigatorConnection(navigator.connection),
|
2021-05-18 04:25:07 +08:00
|
|
|
layoutManagerLoaded,
|
2020-08-29 01:23:27 +08:00
|
|
|
randomlySelectedUser,
|
|
|
|
currentUserId: currentUser.userId,
|
2021-04-15 23:12:10 +08:00
|
|
|
isPresenter: currentUser.presenter,
|
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;
|