2018-01-08 12:44:42 +08:00
|
|
|
import React from 'react';
|
2018-06-04 23:36:38 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2018-10-06 03:23:16 +08:00
|
|
|
import { Session } from 'meteor/session';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2019-01-15 05:39:03 +08:00
|
|
|
import Users from '/imports/api/users';
|
2016-10-05 03:23:43 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-11 06:08:51 +08:00
|
|
|
import { meetingIsBreakout } from '/imports/ui/components/app/service';
|
2018-09-14 02:09:30 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2016-11-07 23:52:39 +08:00
|
|
|
import userListService from '../user-list/service';
|
2016-10-05 03:23:43 +08:00
|
|
|
import ChatService from '../chat/service';
|
2016-11-07 23:52:39 +08:00
|
|
|
import Service from './service';
|
2016-05-20 21:44:27 +08:00
|
|
|
import NavBar from './component';
|
2019-01-15 05:39:03 +08:00
|
|
|
import mapUser from '../../services/user/mapUser';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2018-06-04 23:36:38 +08:00
|
|
|
const PUBLIC_CONFIG = Meteor.settings.public;
|
2018-08-02 01:03:12 +08:00
|
|
|
const PUBLIC_GROUP_CHAT_ID = PUBLIC_CONFIG.chat.public_group_id;
|
2016-10-05 03:23:43 +08:00
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
const NavBarContainer = ({ children, ...props }) => (
|
|
|
|
<NavBar {...props}>
|
|
|
|
{children}
|
|
|
|
</NavBar>
|
|
|
|
);
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2018-10-06 03:23:16 +08:00
|
|
|
export default withTracker(() => {
|
2018-09-14 02:09:30 +08:00
|
|
|
const CLIENT_TITLE = getFromUserSettings('clientTitle', PUBLIC_CONFIG.app.clientTitle);
|
|
|
|
|
2016-07-11 20:34:58 +08:00
|
|
|
let meetingTitle;
|
|
|
|
let meetingRecorded;
|
2016-07-11 21:45:24 +08:00
|
|
|
const meetingId = Auth.meetingID;
|
2016-06-29 02:50:44 +08:00
|
|
|
const meetingObject = Meetings.findOne({
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
2016-06-29 02:50:44 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (meetingObject != null) {
|
2017-08-16 01:24:58 +08:00
|
|
|
meetingTitle = meetingObject.meetingProp.name;
|
2018-02-24 00:26:33 +08:00
|
|
|
meetingRecorded = meetingObject.recordProp;
|
2018-06-04 23:36:38 +08:00
|
|
|
document.title = `${CLIENT_TITLE} - ${meetingTitle}`;
|
2016-06-29 02:50:44 +08:00
|
|
|
}
|
2016-06-18 06:15:11 +08:00
|
|
|
|
2016-10-12 01:36:28 +08:00
|
|
|
const checkUnreadMessages = () => {
|
2017-06-03 03:25:02 +08:00
|
|
|
const users = userListService.getUsers();
|
2016-10-05 03:23:43 +08:00
|
|
|
|
2016-10-12 01:36:28 +08:00
|
|
|
// 1.map every user id
|
|
|
|
// 2.filter the user except the current user from the user array
|
|
|
|
// 3.add the public chat to the array
|
|
|
|
// 4.check current user has unread messages or not.
|
|
|
|
return users
|
|
|
|
.map(user => user.id)
|
|
|
|
.filter(userID => userID !== Auth.userID)
|
2018-08-02 01:03:12 +08:00
|
|
|
.concat(PUBLIC_GROUP_CHAT_ID)
|
2016-10-12 01:36:28 +08:00
|
|
|
.some(receiverID => ChatService.hasUnreadMessages(receiverID));
|
|
|
|
};
|
2016-10-05 03:23:43 +08:00
|
|
|
|
2019-01-04 02:14:35 +08:00
|
|
|
Meetings.find({ meetingId: Auth.meetingID }).observeChanges({
|
|
|
|
changed: (id, fields) => {
|
|
|
|
if (fields.recordProp && fields.recordProp.recording) {
|
|
|
|
this.window.parent.postMessage({ response: 'recordingStarted' }, '*');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fields.recordProp && !fields.recordProp.recording) {
|
|
|
|
this.window.parent.postMessage({ response: 'recordingStopped' }, '*');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
const breakouts = Service.getBreakouts();
|
2017-03-17 22:23:00 +08:00
|
|
|
const currentUserId = Auth.userID;
|
2019-01-09 06:17:11 +08:00
|
|
|
const { connectRecordingObserver, processOutsideToggleRecording } = Service;
|
2016-11-29 03:48:02 +08:00
|
|
|
|
2018-10-25 23:20:37 +08:00
|
|
|
const isExpanded = Session.get('isUserListOpen');
|
2017-03-29 22:31:15 +08:00
|
|
|
|
2019-01-15 05:39:03 +08:00
|
|
|
const amIModerator = () => {
|
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
|
|
|
return mapUser(currentUser).isModerator;
|
|
|
|
};
|
|
|
|
|
2016-07-21 22:24:50 +08:00
|
|
|
return {
|
2019-01-15 05:39:03 +08:00
|
|
|
amIModerator,
|
2017-03-28 02:10:24 +08:00
|
|
|
isExpanded,
|
2016-11-29 03:48:02 +08:00
|
|
|
breakouts,
|
|
|
|
currentUserId,
|
2019-01-09 06:17:11 +08:00
|
|
|
processOutsideToggleRecording,
|
|
|
|
connectRecordingObserver,
|
2016-11-29 03:48:02 +08:00
|
|
|
meetingId,
|
2016-06-25 07:09:32 +08:00
|
|
|
presentationTitle: meetingTitle,
|
2016-10-12 01:36:28 +08:00
|
|
|
hasUnreadMessages: checkUnreadMessages(),
|
2017-03-16 01:54:40 +08:00
|
|
|
isBreakoutRoom: meetingIsBreakout(),
|
2018-12-21 03:39:04 +08:00
|
|
|
recordProps: meetingRecorded,
|
2016-07-21 22:24:50 +08:00
|
|
|
toggleUserList: () => {
|
2018-10-06 03:23:16 +08:00
|
|
|
Session.set('isUserListOpen', !isExpanded);
|
2016-07-21 22:24:50 +08:00
|
|
|
},
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
2018-10-04 00:14:10 +08:00
|
|
|
})(NavBarContainer);
|