bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/nav-bar/container.jsx

89 lines
2.9 KiB
React
Raw Normal View History

import React from 'react';
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
import { Session } from 'meteor/session';
import Meetings, { RecordMeetings } from '/imports/api/meetings';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
2017-10-11 06:08:51 +08:00
import { meetingIsBreakout } from '/imports/ui/components/app/service';
import getFromUserSettings from '/imports/ui/services/users-settings';
import userListService from '../user-list/service';
import Service from './service';
import NavBar from './component';
import mapUser from '../../services/user/mapUser';
2016-04-29 03:02:51 +08:00
const PUBLIC_CONFIG = Meteor.settings.public;
2017-10-11 06:08:51 +08:00
const NavBarContainer = ({ children, ...props }) => (
<NavBar {...props}>
{children}
</NavBar>
);
2016-04-29 03:02:51 +08:00
export default withTracker(() => {
const CLIENT_TITLE = getFromUserSettings('clientTitle', PUBLIC_CONFIG.app.clientTitle);
2016-07-11 20:34:58 +08:00
let meetingTitle;
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
});
const recordObeject = RecordMeetings.findOne({ meetingId });
2016-06-29 02:50:44 +08:00
if (meetingObject != null) {
2017-08-16 01:24:58 +08:00
meetingTitle = meetingObject.meetingProp.name;
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 = () => {
const activeChats = userListService.getActiveChats();
const hasUnreadMessages = activeChats
.filter(chat => chat.id !== Session.get('idChatOpen'))
.some(chat => chat.unreadCounter > 0);
return hasUnreadMessages;
2016-10-12 01:36:28 +08:00
};
RecordMeetings.find({ meetingId: Auth.meetingID }, { fields: { recording: 1 } }).observeChanges({
2019-01-04 02:14:35 +08:00
changed: (id, fields) => {
if (fields && fields.recording) {
2019-01-04 02:14:35 +08:00
this.window.parent.postMessage({ response: 'recordingStarted' }, '*');
}
if (fields && !fields.recording) {
2019-01-04 02:14:35 +08:00
this.window.parent.postMessage({ response: 'recordingStopped' }, '*');
}
},
});
const currentUserId = Auth.userID;
2019-01-09 06:17:11 +08:00
const { connectRecordingObserver, processOutsideToggleRecording } = Service;
2019-04-04 04:51:18 +08:00
const currentUser = Users.findOne({ userId: Auth.userID });
const openPanel = Session.get('openPanel');
const isExpanded = openPanel !== '';
2019-04-04 04:51:18 +08:00
const amIModerator = mapUser(currentUser).isModerator;
2019-08-15 04:49:16 +08:00
const isBreakoutRoom = meetingIsBreakout();
const hasUnreadMessages = checkUnreadMessages();
2019-08-15 04:49:16 +08:00
const toggleUserList = () => {
Session.set('isUserListOpen', !isExpanded);
};
2016-07-21 22:24:50 +08:00
return {
amIModerator,
2017-03-28 02:10:24 +08:00
isExpanded,
2016-11-29 03:48:02 +08:00
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,
2019-08-15 04:49:16 +08:00
hasUnreadMessages,
isBreakoutRoom,
toggleUserList,
allowStartStopRecording: !!(recordObeject && recordObeject.allowStartStopRecording),
autoStartRecording: recordObeject && recordObeject.autoStartRecording,
record: recordObeject && recordObeject.record,
recording: recordObeject && recordObeject.recording,
time: recordObeject && recordObeject.time,
2016-04-29 03:02:51 +08:00
};
})(NavBarContainer);