2021-02-19 04:11:02 +08:00
|
|
|
import React, { useContext } from 'react';
|
2024-06-11 22:46:16 +08:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
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';
|
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';
|
2023-09-22 02:10:30 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2022-10-06 03:37:49 +08:00
|
|
|
import { PANELS } from '/imports/ui/components/layout/enums';
|
2023-11-30 21:24:25 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-02-21 01:32:15 +08:00
|
|
|
import useChat from '/imports/ui/core/hooks/useChat';
|
2024-05-01 20:39:03 +08:00
|
|
|
import useHasUnreadNotes from '../notes/hooks/useHasUnreadNotes';
|
2024-04-25 04:18:21 +08:00
|
|
|
import { useShortcut } from '../../core/hooks/useShortcut';
|
2024-06-11 22:46:16 +08:00
|
|
|
import useMeeting from '../../core/hooks/useMeeting';
|
|
|
|
import { registerTitleView } from '/imports/utils/dom-utils';
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
defaultViewLabel: {
|
|
|
|
id: 'app.title.defaultViewLabel',
|
|
|
|
description: 'view name appended to document title',
|
|
|
|
},
|
|
|
|
});
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2021-02-19 04:11:02 +08:00
|
|
|
const NavBarContainer = ({ children, ...props }) => {
|
2023-11-29 02:31:28 +08:00
|
|
|
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
|
2024-01-16 03:49:09 +08:00
|
|
|
const unread = useHasUnreadNotes();
|
2024-06-11 22:46:16 +08:00
|
|
|
const intl = useIntl();
|
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;
|
|
|
|
|
2024-04-25 04:18:21 +08:00
|
|
|
const toggleUserList = useShortcut('toggleUserList');
|
|
|
|
|
2022-11-04 02:11:57 +08:00
|
|
|
const hasUnreadNotes = sidebarContentPanel !== PANELS.SHARED_NOTES && unread && !notesIsPinned;
|
2024-02-21 01:32:15 +08:00
|
|
|
|
|
|
|
const { data: chats } = useChat((chat) => ({
|
|
|
|
totalUnread: chat.totalUnread,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const hasUnreadMessages = chats && chats.reduce((acc, chat) => acc + chat?.totalUnread, 0) > 0;
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2023-11-30 21:24:25 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
isModerator: user.isModerator,
|
|
|
|
}));
|
|
|
|
const amIModerator = currentUserData?.isModerator;
|
2021-02-19 04:11:02 +08:00
|
|
|
|
2023-11-30 21:24:25 +08:00
|
|
|
const isExpanded = !!sidebarContentPanel || !!sidebarNavPanel;
|
2021-04-07 03:58:11 +08:00
|
|
|
|
2021-10-20 04:43:33 +08:00
|
|
|
const hideNavBar = getFromUserSettings('bbb_hide_nav_bar', false);
|
|
|
|
|
2024-06-11 22:46:16 +08:00
|
|
|
const PUBLIC_CONFIG = window.meetingClientSettings.public;
|
|
|
|
const CLIENT_TITLE = getFromUserSettings('bbb_client_title', PUBLIC_CONFIG.app.clientTitle);
|
|
|
|
const IS_DIRECT_LEAVE_BUTTON_ENABLED = getFromUserSettings(
|
|
|
|
'bbb_direct_leave_button',
|
|
|
|
PUBLIC_CONFIG.app.defaultSettings.application.directLeaveButton,
|
|
|
|
);
|
|
|
|
|
|
|
|
let meetingTitle;
|
|
|
|
let breakoutNum;
|
|
|
|
let breakoutName;
|
|
|
|
let meetingName;
|
|
|
|
|
|
|
|
const { data: meeting } = useMeeting((m) => ({
|
|
|
|
name: m.name,
|
|
|
|
meetingId: m.meetingId,
|
|
|
|
breakoutPolicies: {
|
|
|
|
sequence: m.breakoutPolicies.sequence,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (meeting) {
|
|
|
|
meetingTitle = meeting.name;
|
|
|
|
const titleString = `${CLIENT_TITLE} - ${meetingTitle}`;
|
|
|
|
document.title = titleString;
|
|
|
|
registerTitleView(intl.formatMessage(intlMessages.defaultViewLabel));
|
2024-06-11 23:13:10 +08:00
|
|
|
|
|
|
|
if (meeting.breakoutPolicies) {
|
|
|
|
breakoutNum = meeting.breakoutPolicies.sequence;
|
|
|
|
if (breakoutNum > 0) {
|
|
|
|
breakoutName = meetingTitle;
|
|
|
|
meetingName = meetingTitle.replace(`(${breakoutName})`, '').trim();
|
|
|
|
}
|
|
|
|
}
|
2024-06-11 22:46:16 +08:00
|
|
|
}
|
|
|
|
|
2022-07-30 03:02:31 +08:00
|
|
|
if (hideNavBar || navBar.display === false) return null;
|
2021-10-20 04:43:33 +08:00
|
|
|
|
2023-09-22 02:10:30 +08:00
|
|
|
let pluginNavBarItems = [];
|
2023-11-29 02:31:28 +08:00
|
|
|
if (pluginsExtensibleAreasAggregatedState.navBarItems) {
|
2023-09-22 02:10:30 +08:00
|
|
|
pluginNavBarItems = [
|
2023-11-29 02:31:28 +08:00
|
|
|
...pluginsExtensibleAreasAggregatedState.navBarItems,
|
2023-09-22 02:10:30 +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,
|
2023-02-08 19:47:26 +08:00
|
|
|
currentUserId: Auth.userID,
|
2023-09-22 02:10:30 +08:00
|
|
|
pluginNavBarItems,
|
2024-04-25 04:18:21 +08:00
|
|
|
shortcuts: toggleUserList,
|
2024-06-15 03:17:31 +08:00
|
|
|
meetingId: meeting?.meetingId,
|
2024-06-11 22:46:16 +08:00
|
|
|
presentationTitle: meetingTitle,
|
|
|
|
breakoutNum,
|
|
|
|
breakoutName,
|
|
|
|
meetingName,
|
|
|
|
isDirectLeaveButtonEnabled: IS_DIRECT_LEAVE_BUTTON_ENABLED,
|
2024-06-15 03:54:31 +08:00
|
|
|
// TODO: Remove/Replace
|
|
|
|
isMeteorConnected: true,
|
2024-01-16 03:49:09 +08:00
|
|
|
...props,
|
2021-05-18 04:25:07 +08:00
|
|
|
}}
|
|
|
|
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
|
|
|
|
2024-06-11 22:46:16 +08:00
|
|
|
export default NavBarContainer;
|