2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
2016-07-21 22:24:50 +08:00
|
|
|
import { withRouter } from 'react-router';
|
2016-06-18 06:15:11 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2016-10-05 03:23:43 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
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';
|
2017-03-16 00:21:26 +08:00
|
|
|
import { meetingIsBreakout } from '/imports/ui/components/app/service';
|
2016-05-20 21:44:27 +08:00
|
|
|
import NavBar from './component';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2016-10-05 03:23:43 +08:00
|
|
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
|
|
|
const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id;
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
class NavBarContainer extends Component {
|
2016-04-29 03:02:51 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2017-03-16 01:54:40 +08:00
|
|
|
<NavBar {...this.props}>
|
2016-04-29 03:02:51 +08:00
|
|
|
{this.props.children}
|
2016-05-04 22:48:53 +08:00
|
|
|
</NavBar>
|
2016-04-29 03:02:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 22:24:50 +08:00
|
|
|
export default withRouter(createContainer(({ location, router }) => {
|
2017-03-28 02:10:24 +08:00
|
|
|
|
2016-07-11 20:34:58 +08:00
|
|
|
let meetingTitle;
|
|
|
|
let meetingRecorded;
|
2016-06-18 06:15:11 +08:00
|
|
|
|
2016-07-11 21:45:24 +08:00
|
|
|
const meetingId = Auth.meetingID;
|
2016-06-29 02:50:44 +08:00
|
|
|
const meetingObject = Meetings.findOne({
|
|
|
|
meetingId: meetingId,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (meetingObject != null) {
|
|
|
|
meetingTitle = meetingObject.meetingName;
|
|
|
|
meetingRecorded = meetingObject.currentlyBeingRecorded;
|
|
|
|
}
|
2016-06-18 06:15:11 +08:00
|
|
|
|
2016-10-12 01:36:28 +08:00
|
|
|
const checkUnreadMessages = () => {
|
2016-11-07 23:52:39 +08:00
|
|
|
let 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)
|
|
|
|
.concat(PUBLIC_CHAT_KEY)
|
|
|
|
.some(receiverID => ChatService.hasUnreadMessages(receiverID));
|
|
|
|
};
|
2016-10-05 03:23:43 +08:00
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
const breakouts = Service.getBreakouts();
|
2017-03-17 22:23:00 +08:00
|
|
|
const currentUserId = Auth.userID;
|
2016-11-29 03:48:02 +08:00
|
|
|
|
2017-03-29 22:31:15 +08:00
|
|
|
let isExpanded = location.pathname.indexOf('/users') !== -1;
|
|
|
|
|
2016-07-21 22:24:50 +08:00
|
|
|
return {
|
2017-03-28 02:10:24 +08:00
|
|
|
isExpanded,
|
2016-11-29 03:48:02 +08:00
|
|
|
breakouts,
|
|
|
|
currentUserId,
|
|
|
|
meetingId,
|
|
|
|
getBreakoutJoinURL: Service.getBreakoutJoinURL,
|
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(),
|
2016-06-29 02:50:44 +08:00
|
|
|
beingRecorded: meetingRecorded,
|
2016-07-21 22:24:50 +08:00
|
|
|
toggleUserList: () => {
|
|
|
|
if (location.pathname.indexOf('/users') !== -1) {
|
|
|
|
router.push('/');
|
|
|
|
} else {
|
|
|
|
router.push('/users');
|
|
|
|
}
|
|
|
|
},
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
2016-07-21 22:24:50 +08:00
|
|
|
}, NavBarContainer));
|