2024-09-11 04:10:28 +08:00
|
|
|
import React, { useContext, useState, useEffect } from 'react';
|
2023-03-10 19:30:46 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2022-02-19 04:45:16 +08:00
|
|
|
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';
|
2023-09-20 04:34:14 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2023-10-11 22:21:35 +08:00
|
|
|
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';
|
2022-02-19 04:45:16 +08:00
|
|
|
|
2023-12-06 02:15:25 +08:00
|
|
|
import {
|
|
|
|
persistShape,
|
|
|
|
} from '/imports/ui/components/whiteboard/service';
|
2024-06-27 20:38:38 +08:00
|
|
|
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
|
2023-12-06 02:15:25 +08:00
|
|
|
|
2022-02-19 04:45:16 +08:00
|
|
|
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;
|
2022-03-26 00:38:57 +08:00
|
|
|
const isFullscreen = currentElement === elementId;
|
2024-06-27 20:38:38 +08:00
|
|
|
const Settings = getSettingsSingletonInstance();
|
|
|
|
const { isRTL } = Settings.application;
|
2023-11-29 02:31:28 +08:00
|
|
|
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
|
2023-09-20 04:34:14 +08:00
|
|
|
let presentationDropdownItems = [];
|
2023-11-29 02:31:28 +08:00
|
|
|
if (pluginsExtensibleAreasAggregatedState.presentationDropdownItems) {
|
2023-09-20 04:34:14 +08:00
|
|
|
presentationDropdownItems = [
|
2023-11-29 02:31:28 +08:00
|
|
|
...pluginsExtensibleAreasAggregatedState.presentationDropdownItems,
|
2023-09-20 04:34:14 +08:00
|
|
|
];
|
|
|
|
}
|
2022-02-19 04:45:16 +08:00
|
|
|
|
2024-09-11 04:10:28 +08:00
|
|
|
const [whiteboardWriters, setWhiteboardWriters] = useState([]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
const { data } = await useDeduplicatedSubscription(
|
|
|
|
CURRENT_PAGE_WRITERS_SUBSCRIPTION,
|
|
|
|
{
|
|
|
|
variables: { pageId: whiteboardId },
|
|
|
|
skip: !whiteboardId,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
setWhiteboardWriters(data?.pres_page_writers || []);
|
|
|
|
};
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
}, [whiteboardId]);
|
2023-10-11 22:21:35 +08:00
|
|
|
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
|
|
|
|
2022-02-19 04:45:16 +08:00
|
|
|
return (
|
|
|
|
<PresentationMenu
|
|
|
|
{...props}
|
|
|
|
{...{
|
|
|
|
currentElement,
|
|
|
|
currentGroup,
|
2022-03-26 00:38:57 +08:00
|
|
|
isFullscreen,
|
2022-02-19 04:45:16 +08:00
|
|
|
layoutContextDispatch,
|
2022-06-17 00:32:27 +08:00
|
|
|
isRTL,
|
2023-09-20 04:34:14 +08:00
|
|
|
presentationDropdownItems,
|
2023-10-11 22:21:35 +08:00
|
|
|
hasWBAccess,
|
2023-10-13 02:05:49 +08:00
|
|
|
meetingName: meetingInfo?.name,
|
|
|
|
handleToggleFullscreen,
|
|
|
|
isIphone,
|
2024-06-14 21:30:48 +08:00
|
|
|
allowSnapshotOfCurrentSlide,
|
2023-12-06 02:15:25 +08:00
|
|
|
persistShape,
|
2024-09-11 04:10:28 +08:00
|
|
|
whiteboardWriters,
|
2022-02-19 04:45:16 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-10-13 02:05:49 +08:00
|
|
|
export default PresentationMenuContainer;
|
2023-03-10 19:30:46 +08:00
|
|
|
|
|
|
|
PresentationMenuContainer.propTypes = {
|
|
|
|
elementId: PropTypes.string.isRequired,
|
|
|
|
};
|