72 lines
2.4 KiB
JavaScript
Executable File
72 lines
2.4 KiB
JavaScript
Executable File
import React from 'react';
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
import { Session } from 'meteor/session';
|
|
import Meetings from '/imports/api/meetings';
|
|
import Users from '/imports/api/users';
|
|
import Auth from '/imports/ui/services/auth';
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
|
import userListService from '../user-list/service';
|
|
import NoteService from '/imports/ui/components/note/service';
|
|
import Service from './service';
|
|
import NavBar from './component';
|
|
|
|
const PUBLIC_CONFIG = Meteor.settings.public;
|
|
const ROLE_MODERATOR = PUBLIC_CONFIG.user.role_moderator;
|
|
const NavBarContainer = ({ children, ...props }) => (
|
|
<NavBar {...props}>
|
|
{children}
|
|
</NavBar>
|
|
);
|
|
|
|
export default withTracker(() => {
|
|
const CLIENT_TITLE = getFromUserSettings('bbb_client_title', PUBLIC_CONFIG.app.clientTitle);
|
|
|
|
let meetingTitle;
|
|
const meetingId = Auth.meetingID;
|
|
const meetingObject = Meetings.findOne({
|
|
meetingId,
|
|
}, { fields: { 'meetingProp.name': 1, 'breakoutProps.sequence': 1 } });
|
|
|
|
if (meetingObject != null) {
|
|
meetingTitle = meetingObject.meetingProp.name;
|
|
let titleString = `${CLIENT_TITLE} - ${meetingTitle}`;
|
|
if (meetingObject.breakoutProps) {
|
|
const breakoutNum = meetingObject.breakoutProps.sequence;
|
|
if (breakoutNum > 0) {
|
|
titleString = `${breakoutNum} - ${titleString}`;
|
|
}
|
|
}
|
|
document.title = titleString;
|
|
}
|
|
|
|
const checkUnreadMessages = () => {
|
|
const activeChats = userListService.getActiveChats();
|
|
const hasUnreadMessages = activeChats
|
|
.filter(chat => chat.userId !== Session.get('idChatOpen'))
|
|
.some(chat => chat.unreadCounter > 0);
|
|
|
|
const hasUnreadNotes = NoteService.hasUnreadNotes();
|
|
|
|
return hasUnreadMessages || hasUnreadNotes;
|
|
};
|
|
|
|
const { connectRecordingObserver, processOutsideToggleRecording } = Service;
|
|
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { role: 1 } });
|
|
const openPanel = Session.get('openPanel');
|
|
const isExpanded = openPanel !== '';
|
|
const amIModerator = currentUser.role === ROLE_MODERATOR;
|
|
const hasUnreadMessages = checkUnreadMessages();
|
|
|
|
return {
|
|
amIModerator,
|
|
isExpanded,
|
|
currentUserId: Auth.userID,
|
|
processOutsideToggleRecording,
|
|
connectRecordingObserver,
|
|
meetingId,
|
|
presentationTitle: meetingTitle,
|
|
hasUnreadMessages,
|
|
};
|
|
})(NavBarContainer);
|