bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/presentation-menu/container.jsx

78 lines
2.7 KiB
React
Raw Normal View History

2024-06-14 21:30:48 +08:00
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import PresentationMenu from './component';
import FullscreenService from '/imports/ui/components/common/fullscreen-button/service';
import Auth from '/imports/ui/services/auth';
import { layoutSelect, layoutDispatch } from '/imports/ui/components/layout/context';
2024-06-14 21:30:48 +08:00
import { useIsSnapshotOfCurrentSlideEnabled } from '/imports/ui/services/features';
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
import {
CURRENT_PAGE_WRITERS_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
2023-10-13 02:05:49 +08:00
import useMeeting from '/imports/ui/core/hooks/useMeeting';
import {
persistShape,
} from '/imports/ui/components/whiteboard/service';
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
const PresentationMenuContainer = (props) => {
const fullscreen = layoutSelect((i) => i.fullscreen);
const { element: currentElement, group: currentGroup } = fullscreen;
const layoutContextDispatch = layoutDispatch();
2024-06-18 02:20:48 +08:00
const { elementId, whiteboardId } = props;
const isFullscreen = currentElement === elementId;
2022-06-17 00:32:27 +08:00
const isRTL = layoutSelect((i) => i.isRTL);
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
let presentationDropdownItems = [];
if (pluginsExtensibleAreasAggregatedState.presentationDropdownItems) {
presentationDropdownItems = [
...pluginsExtensibleAreasAggregatedState.presentationDropdownItems,
];
}
const { data: whiteboardWritersData } = useDeduplicatedSubscription(
CURRENT_PAGE_WRITERS_SUBSCRIPTION,
2024-06-18 02:20:48 +08:00
{
variables: { pageId: whiteboardId },
skip: !whiteboardId,
},
);
const whiteboardWriters = whiteboardWritersData?.pres_page_writers || [];
const hasWBAccess = whiteboardWriters?.some((writer) => writer.userId === Auth.userID);
2023-10-13 02:05:49 +08:00
const meetingInfo = useMeeting((meeting) => ({
name: meeting?.name,
}));
const handleToggleFullscreen = (ref) => FullscreenService.toggleFullScreen(ref);
const isIphone = !!(navigator.userAgent.match(/iPhone/i));
2024-06-14 21:30:48 +08:00
const allowSnapshotOfCurrentSlide = useIsSnapshotOfCurrentSlideEnabled();
2023-10-13 02:05:49 +08:00
return (
<PresentationMenu
{...props}
{...{
currentElement,
currentGroup,
isFullscreen,
layoutContextDispatch,
2022-06-17 00:32:27 +08:00
isRTL,
presentationDropdownItems,
hasWBAccess,
2023-10-13 02:05:49 +08:00
meetingName: meetingInfo?.name,
handleToggleFullscreen,
isIphone,
2024-06-14 21:30:48 +08:00
allowSnapshotOfCurrentSlide,
persistShape,
}}
/>
);
};
2023-10-13 02:05:49 +08:00
export default PresentationMenuContainer;
PresentationMenuContainer.propTypes = {
elementId: PropTypes.string.isRequired,
};