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

129 lines
4.3 KiB
React
Raw Normal View History

2021-02-19 04:11:02 +08:00
import React, { useContext } from 'react';
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
import Meetings from '/imports/api/meetings';
import Breakouts from '/imports/api/breakouts';
import Auth from '/imports/ui/services/auth';
import getFromUserSettings from '/imports/ui/services/users-settings';
import NotesService from '/imports/ui/components/notes/service';
import NavBar from './component';
2021-09-11 04:48:52 +08:00
import { layoutSelectInput, layoutSelectOutput, layoutDispatch } from '../layout/context';
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';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
2024-02-21 01:32:15 +08:00
import useChat from '/imports/ui/core/hooks/useChat';
import useHasUnreadNotes from '../notes/notes-graphql/hooks/useHasUnreadNotes';
2016-04-29 03:02:51 +08:00
const PUBLIC_CONFIG = window.meetingClientSettings.public;
2021-02-19 04:11:02 +08:00
const NavBarContainer = ({ children, ...props }) => {
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
const unread = useHasUnreadNotes();
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;
const { sidebarContentPanel } = sidebarContent;
const { sidebarNavPanel } = sidebarNavigation;
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
const { data: currentUserData } = useCurrentUser((user) => ({
isModerator: user.isModerator,
}));
const amIModerator = currentUserData?.isModerator;
2021-02-19 04:11:02 +08:00
const isExpanded = !!sidebarContentPanel || !!sidebarNavPanel;
const hideNavBar = getFromUserSettings('bbb_hide_nav_bar', false);
if (hideNavBar || navBar.display === false) return null;
let pluginNavBarItems = [];
if (pluginsExtensibleAreasAggregatedState.navBarItems) {
pluginNavBarItems = [
...pluginsExtensibleAreasAggregatedState.navBarItems,
];
}
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,
currentUserId: Auth.userID,
pluginNavBarItems,
...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
export default withTracker(() => {
const CLIENT_TITLE = getFromUserSettings('bbb_client_title', PUBLIC_CONFIG.app.clientTitle);
2022-10-06 03:37:49 +08:00
const unread = NotesService.hasUnreadNotes();
let meetingTitle, breakoutNum, breakoutName, meetingName;
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,
}, { fields: { name: 1, 'breakoutPolicies.sequence': 1, meetingId: 1 } });
2016-06-29 02:50:44 +08:00
if (meetingObject != null) {
meetingTitle = meetingObject.name;
let titleString = `${CLIENT_TITLE} - ${meetingTitle}`;
document.title = titleString;
if (meetingObject.breakoutPolicies) {
breakoutNum = meetingObject.breakoutPolicies.sequence;
if (breakoutNum > 0) {
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();
}
}
}
2016-06-29 02:50:44 +08:00
}
2016-06-18 06:15:11 +08:00
2023-11-21 00:30:07 +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 {
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,
breakoutNum,
breakoutName,
meetingName,
2022-10-06 03:37:49 +08:00
unread,
2023-11-21 00:30:07 +08:00
isDirectLeaveButtonEnabled: IS_DIRECT_LEAVE_BUTTON_ENABLED,
isMeteorConnected: Meteor.status().connected,
2016-04-29 03:02:51 +08:00
};
})(NavBarContainer);