2021-02-19 04:11:02 +08:00
|
|
|
import React, { useContext } 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';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2022-01-14 20:59:31 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2016-10-05 03:23:43 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2018-09-14 02:09:30 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2021-05-18 04:25:07 +08:00
|
|
|
import userListService from '/imports/ui/components/user-list/service';
|
2021-02-19 04:11:02 +08:00
|
|
|
import { ChatContext } from '/imports/ui/components/components-data/chat-context/context';
|
|
|
|
import { GroupChatContext } from '/imports/ui/components/components-data/group-chat-context/context';
|
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
2021-10-16 03:07:13 +08:00
|
|
|
import NotesService from '/imports/ui/components/notes/service';
|
2016-05-20 21:44:27 +08:00
|
|
|
import NavBar from './component';
|
2021-09-11 04:48:52 +08:00
|
|
|
import { layoutSelectInput, layoutSelectOutput, layoutDispatch } from '../layout/context';
|
2022-10-06 03:37:49 +08:00
|
|
|
import { PANELS } from '/imports/ui/components/layout/enums';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2018-06-04 23:36:38 +08:00
|
|
|
const PUBLIC_CONFIG = Meteor.settings.public;
|
2019-08-22 02:57:34 +08:00
|
|
|
const ROLE_MODERATOR = PUBLIC_CONFIG.user.role_moderator;
|
2021-02-19 04:11:02 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const checkUnreadMessages = ({
|
|
|
|
groupChatsMessages, groupChats, users, idChatOpen,
|
|
|
|
}) => {
|
2021-02-19 04:11:02 +08:00
|
|
|
const activeChats = userListService.getActiveChats({ groupChatsMessages, groupChats, users });
|
|
|
|
const hasUnreadMessages = activeChats
|
2021-05-18 04:25:07 +08:00
|
|
|
.filter((chat) => chat.userId !== idChatOpen)
|
|
|
|
.some((chat) => chat.unreadCounter > 0);
|
2021-02-19 04:11:02 +08:00
|
|
|
|
|
|
|
return hasUnreadMessages;
|
|
|
|
};
|
|
|
|
|
|
|
|
const NavBarContainer = ({ children, ...props }) => {
|
|
|
|
const usingChatContext = useContext(ChatContext);
|
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const usingGroupChatContext = useContext(GroupChatContext);
|
|
|
|
const { chats: groupChatsMessages } = usingChatContext;
|
|
|
|
const { users } = usingUsersContext;
|
|
|
|
const { groupChat: groupChats } = usingGroupChatContext;
|
2022-01-13 00:40:45 +08:00
|
|
|
const activeChats = userListService.getActiveChats({ groupChatsMessages, groupChats, users:users[Auth.meetingID] });
|
2022-10-06 03:37:49 +08:00
|
|
|
const { unread, ...rest } = props;
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-09-11 04:48:52 +08:00
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
|
|
|
const sidebarNavigation = layoutSelectInput((i) => i.sidebarNavigation);
|
|
|
|
const navBar = layoutSelectOutput((i) => i.navBar);
|
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2022-11-04 02:11:57 +08:00
|
|
|
const sharedNotes = layoutSelectInput((i) => i.sharedNotes);
|
|
|
|
const { isPinned: notesIsPinned } = sharedNotes;
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
const { sidebarContentPanel } = sidebarContent;
|
2021-09-10 21:16:44 +08:00
|
|
|
const { sidebarNavPanel } = sidebarNavigation;
|
|
|
|
|
2022-11-04 02:11:57 +08:00
|
|
|
const hasUnreadNotes = sidebarContentPanel !== PANELS.SHARED_NOTES && unread && !notesIsPinned;
|
2021-05-18 04:25:07 +08:00
|
|
|
const hasUnreadMessages = checkUnreadMessages(
|
|
|
|
{ groupChatsMessages, groupChats, users: users[Auth.meetingID] },
|
|
|
|
);
|
|
|
|
|
|
|
|
const isExpanded = !!sidebarContentPanel || !!sidebarNavPanel;
|
2021-02-19 04:11:02 +08:00
|
|
|
|
2021-04-15 20:12:21 +08:00
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
2021-04-07 03:58:11 +08:00
|
|
|
const amIModerator = currentUser.role === ROLE_MODERATOR;
|
|
|
|
|
2021-10-20 04:43:33 +08:00
|
|
|
const hideNavBar = getFromUserSettings('bbb_hide_nav_bar', false);
|
|
|
|
|
2022-07-30 03:02:31 +08:00
|
|
|
if (hideNavBar || navBar.display === false) return null;
|
2021-10-20 04:43:33 +08:00
|
|
|
|
2021-02-19 04:11:02 +08:00
|
|
|
return (
|
2021-05-18 04:25:07 +08:00
|
|
|
<NavBar
|
|
|
|
{...{
|
|
|
|
amIModerator,
|
|
|
|
hasUnreadMessages,
|
|
|
|
hasUnreadNotes,
|
|
|
|
sidebarNavPanel,
|
|
|
|
sidebarContentPanel,
|
|
|
|
sidebarNavigation,
|
|
|
|
sidebarContent,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-05-18 04:25:07 +08:00
|
|
|
isExpanded,
|
2021-12-28 13:40:51 +08:00
|
|
|
activeChats,
|
2023-02-08 19:47:26 +08:00
|
|
|
currentUserId: Auth.userID,
|
2021-05-18 04:25:07 +08:00
|
|
|
...rest,
|
|
|
|
}}
|
|
|
|
style={{ ...navBar }}
|
|
|
|
>
|
2021-02-19 04:11:02 +08:00
|
|
|
{children}
|
|
|
|
</NavBar>
|
|
|
|
);
|
2021-05-18 04:25:07 +08:00
|
|
|
};
|
2021-02-19 04:11:02 +08:00
|
|
|
|
2018-10-06 03:23:16 +08:00
|
|
|
export default withTracker(() => {
|
2019-07-25 01:04:46 +08:00
|
|
|
const CLIENT_TITLE = getFromUserSettings('bbb_client_title', PUBLIC_CONFIG.app.clientTitle);
|
2022-10-06 03:37:49 +08:00
|
|
|
const unread = NotesService.hasUnreadNotes();
|
2018-09-14 02:09:30 +08:00
|
|
|
|
2022-01-14 20:59:31 +08:00
|
|
|
let meetingTitle, breakoutNum, breakoutName, meetingName;
|
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,
|
2022-01-14 20:59:31 +08:00
|
|
|
}, { fields: { 'meetingProp.name': 1, 'breakoutProps.sequence': 1, meetingId: 1 } });
|
2016-06-29 02:50:44 +08:00
|
|
|
|
|
|
|
if (meetingObject != null) {
|
2017-08-16 01:24:58 +08:00
|
|
|
meetingTitle = meetingObject.meetingProp.name;
|
2019-10-02 02:42:10 +08:00
|
|
|
let titleString = `${CLIENT_TITLE} - ${meetingTitle}`;
|
2022-01-14 20:59:31 +08:00
|
|
|
document.title = titleString;
|
|
|
|
|
2019-10-02 02:42:10 +08:00
|
|
|
if (meetingObject.breakoutProps) {
|
2022-01-14 20:59:31 +08:00
|
|
|
breakoutNum = meetingObject.breakoutProps.sequence;
|
2019-10-02 02:42:10 +08:00
|
|
|
if (breakoutNum > 0) {
|
2022-01-14 20:59:31 +08:00
|
|
|
const breakoutObject = Breakouts.findOne({
|
|
|
|
breakoutId: meetingObject.meetingId,
|
|
|
|
}, { fields: { shortName: 1 } });
|
2022-01-27 01:16:10 +08:00
|
|
|
if (breakoutObject) {
|
|
|
|
breakoutName = breakoutObject.shortName;
|
|
|
|
meetingName = meetingTitle.replace(`(${breakoutName})`, '').trim();
|
|
|
|
}
|
2019-10-02 02:42:10 +08:00
|
|
|
}
|
|
|
|
}
|
2016-06-29 02:50:44 +08:00
|
|
|
}
|
2016-06-18 06:15:11 +08:00
|
|
|
|
2023-11-07 20:54:17 +08:00
|
|
|
const IS_DIRECT_LEAVE_BUTTON_ENABLED = getFromUserSettings(
|
|
|
|
'bbb_direct_leave_button',
|
|
|
|
PUBLIC_CONFIG.app.defaultSettings.application.directLeaveButton,
|
|
|
|
);
|
|
|
|
|
2016-07-21 22:24:50 +08:00
|
|
|
return {
|
2023-03-28 03:58:48 +08:00
|
|
|
isPinned: NotesService.isSharedNotesPinned(),
|
2019-09-05 02:32:58 +08:00
|
|
|
currentUserId: Auth.userID,
|
2016-11-29 03:48:02 +08:00
|
|
|
meetingId,
|
2016-06-25 07:09:32 +08:00
|
|
|
presentationTitle: meetingTitle,
|
2022-01-14 20:59:31 +08:00
|
|
|
breakoutNum,
|
|
|
|
breakoutName,
|
|
|
|
meetingName,
|
2022-10-06 03:37:49 +08:00
|
|
|
unread,
|
2023-11-07 20:54:17 +08:00
|
|
|
isDirectLeaveButtonEnabled: IS_DIRECT_LEAVE_BUTTON_ENABLED,
|
|
|
|
isMeteorConnected: Meteor.status().connected,
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
2023-11-07 20:54:17 +08:00
|
|
|
})(NavBarContainer);
|