2021-11-23 21:40:23 +08:00
|
|
|
import React, { useContext } from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2024-06-04 21:40:54 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2022-02-15 22:42:02 +08:00
|
|
|
import FullscreenService from '/imports/ui/components/common/fullscreen-button/service';
|
2024-07-08 21:18:26 +08:00
|
|
|
import { useIsInfiniteWhiteboardEnabled, useIsPollingEnabled } from '/imports/ui/services/features';
|
2023-08-16 06:31:11 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2023-12-11 21:31:13 +08:00
|
|
|
import { POLL_CANCEL, POLL_CREATE } from '/imports/ui/components/poll/mutations';
|
2024-07-06 04:09:19 +08:00
|
|
|
import { PRESENTATION_SET_ZOOM, PRESENTATION_SET_PAGE, PRESENTATION_SET_PAGE_INFINITE_WHITEBOARD } from '../mutations';
|
2024-05-17 04:03:36 +08:00
|
|
|
import PresentationToolbar from './component';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2024-07-07 01:36:21 +08:00
|
|
|
import { useMeetingIsBreakout } from '/imports/ui/components/app/service';
|
2020-01-11 03:00:06 +08:00
|
|
|
|
2024-07-06 04:09:19 +08:00
|
|
|
const infiniteWhiteboardIcon = (isinfiniteWhiteboard) => {
|
|
|
|
if (isinfiniteWhiteboard) {
|
2024-06-14 21:58:32 +08:00
|
|
|
return (
|
|
|
|
<svg
|
|
|
|
width="16"
|
|
|
|
height="16"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="none"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fillRule="evenodd"
|
|
|
|
clipRule="evenodd"
|
|
|
|
d="M14.6667 3H1.33333C1.14924 3 1 3.14924 1 3.33333V13.3333C1 13.5174
|
|
|
|
1.14924 13.6667 1.33333 13.6667H14.6667C14.8508 13.6667 15 13.5174 15 13.3333V3.33333C15
|
|
|
|
3.14924 14.8508 3 14.6667 3ZM1.33333 2C0.596954 2 0 2.59695 0 3.33333V13.3333C0 14.0697
|
|
|
|
0.596953 14.6667 1.33333 14.6667H14.6667C15.403 14.6667 16 14.0697 16 13.3333V3.33333C16
|
|
|
|
2.59695 15.403 2 14.6667 2H1.33333Z"
|
|
|
|
fill="#4E5A66"
|
|
|
|
/>
|
|
|
|
<path
|
|
|
|
d="M12.875 11.875L9.125 8.125M9.125 8.125L9.125 10.9375M9.125 8.125L11.9375 8.125"
|
|
|
|
stroke="#4E5A66"
|
|
|
|
strokeLinecap="round"
|
|
|
|
strokeLinejoin="round"
|
|
|
|
/>
|
|
|
|
<path
|
|
|
|
d="M3.125 5.125L6.875 8.875M6.875 8.875L6.875 6.0625M6.875 8.875L4.0625 8.875"
|
|
|
|
stroke="#4E5A66"
|
|
|
|
strokeLinecap="round"
|
|
|
|
strokeLinejoin="round"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<svg
|
|
|
|
width="16"
|
|
|
|
height="16"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="none"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fillRule="evenodd"
|
|
|
|
clipRule="evenodd"
|
|
|
|
d="M14.6667 3H1.33333C1.14924 3 1 3.14924 1 3.33333V13.3333C1 13.5174
|
|
|
|
1.14924 13.6667 1.33333 13.6667H14.6667C14.8508 13.6667 15 13.5174 15 13.3333V3.33333C15
|
|
|
|
3.14924 14.8508 3 14.6667 3ZM1.33333 2C0.596954 2 0 2.59695 0 3.33333V13.3333C0 14.0697
|
|
|
|
0.596953 14.6667 1.33333 14.6667H14.6667C15.403 14.6667 16 14.0697 16 13.3333V3.33333C16
|
|
|
|
2.59695 15.403 2 14.6667 2H1.33333Z"
|
|
|
|
fill="#4E5A66"
|
|
|
|
/>
|
|
|
|
<path
|
|
|
|
d="M9.125 8.125L12.875 11.875M12.875 11.875L12.875 9.0625M12.875 11.875L10.0625 11.875"
|
|
|
|
stroke="#4E5A66"
|
|
|
|
strokeLinecap="round"
|
|
|
|
strokeLinejoin="round"
|
|
|
|
/>
|
|
|
|
<path
|
|
|
|
d="M6.875 8.875L3.125 5.125M3.125 5.125L3.125 7.9375M3.125 5.125L5.9375 5.125"
|
|
|
|
stroke="#4E5A66"
|
|
|
|
strokeLinecap="round"
|
|
|
|
strokeLinejoin="round"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2017-09-26 07:45:44 +08:00
|
|
|
const PresentationToolbarContainer = (props) => {
|
2023-08-16 06:31:11 +08:00
|
|
|
const pluginsContext = useContext(PluginsContext);
|
2023-11-29 02:31:28 +08:00
|
|
|
const { pluginsExtensibleAreasAggregatedState } = pluginsContext;
|
2021-11-23 21:40:23 +08:00
|
|
|
|
2024-06-14 21:58:32 +08:00
|
|
|
const WHITEBOARD_CONFIG = window.meetingClientSettings.public.whiteboard;
|
|
|
|
|
2024-01-20 22:01:20 +08:00
|
|
|
const {
|
|
|
|
userIsPresenter,
|
|
|
|
layoutSwapped,
|
|
|
|
currentSlideNum,
|
|
|
|
presentationId,
|
2024-05-16 23:40:12 +08:00
|
|
|
numberOfSlides,
|
2024-06-13 22:18:07 +08:00
|
|
|
hasPoll,
|
2024-06-14 21:58:32 +08:00
|
|
|
currentSlide,
|
|
|
|
currentPresentationPage,
|
2024-01-20 22:01:20 +08:00
|
|
|
} = props;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2022-02-04 21:57:54 +08:00
|
|
|
const handleToggleFullScreen = (ref) => FullscreenService.toggleFullScreen(ref);
|
|
|
|
|
2023-12-09 04:24:57 +08:00
|
|
|
const [stopPoll] = useMutation(POLL_CANCEL);
|
2023-12-11 21:31:13 +08:00
|
|
|
const [createPoll] = useMutation(POLL_CREATE);
|
2024-07-04 01:05:06 +08:00
|
|
|
const [presentationSetZoom] = useMutation(PRESENTATION_SET_ZOOM);
|
2024-01-20 22:01:20 +08:00
|
|
|
const [presentationSetPage] = useMutation(PRESENTATION_SET_PAGE);
|
2024-07-06 04:09:19 +08:00
|
|
|
const [presentationSetPageInfiniteWhiteboard] = useMutation(PRESENTATION_SET_PAGE_INFINITE_WHITEBOARD);
|
2023-12-09 04:24:57 +08:00
|
|
|
|
2024-07-04 01:05:06 +08:00
|
|
|
const resetSlide = () => {
|
|
|
|
const { pageId, num } = currentPresentationPage;
|
|
|
|
presentationSetZoom({
|
|
|
|
variables: {
|
|
|
|
presentationId,
|
|
|
|
pageId,
|
|
|
|
pageNum: num,
|
|
|
|
xOffset: 0,
|
|
|
|
yOffset: 0,
|
|
|
|
widthRatio: 100,
|
|
|
|
heightRatio: 100,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-03-16 02:06:59 +08:00
|
|
|
const endCurrentPoll = () => {
|
2023-12-09 04:24:57 +08:00
|
|
|
if (hasPoll) stopPoll();
|
2023-03-16 02:24:34 +08:00
|
|
|
};
|
2023-03-16 02:06:59 +08:00
|
|
|
|
2024-01-20 22:01:20 +08:00
|
|
|
const setPresentationPage = (pageId) => {
|
|
|
|
presentationSetPage({
|
|
|
|
variables: {
|
|
|
|
presentationId,
|
|
|
|
pageId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-07-06 04:09:19 +08:00
|
|
|
const setPresentationPageInfiniteWhiteboard = (infiniteWhiteboard) => {
|
2024-06-14 21:58:32 +08:00
|
|
|
const pageId = `${presentationId}/${currentSlideNum}`;
|
2024-07-06 04:09:19 +08:00
|
|
|
presentationSetPageInfiniteWhiteboard({
|
2024-06-14 21:58:32 +08:00
|
|
|
variables: {
|
|
|
|
pageId,
|
2024-07-06 04:09:19 +08:00
|
|
|
infiniteWhiteboard,
|
2024-06-14 21:58:32 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-01-20 22:01:20 +08:00
|
|
|
const skipToSlide = (slideNum) => {
|
|
|
|
const slideId = `${presentationId}/${slideNum}`;
|
|
|
|
setPresentationPage(slideId);
|
|
|
|
};
|
|
|
|
|
|
|
|
const previousSlide = () => {
|
|
|
|
const prevSlideNum = currentSlideNum - 1;
|
2024-05-16 23:40:12 +08:00
|
|
|
if (prevSlideNum < 1) {
|
|
|
|
return;
|
|
|
|
}
|
2024-01-20 22:01:20 +08:00
|
|
|
skipToSlide(prevSlideNum);
|
|
|
|
};
|
|
|
|
|
|
|
|
const nextSlide = () => {
|
|
|
|
const nextSlideNum = currentSlideNum + 1;
|
2024-05-16 23:40:12 +08:00
|
|
|
if (nextSlideNum > numberOfSlides) {
|
|
|
|
return;
|
|
|
|
}
|
2024-01-20 22:01:20 +08:00
|
|
|
skipToSlide(nextSlideNum);
|
|
|
|
};
|
|
|
|
|
2023-12-11 21:31:13 +08:00
|
|
|
const startPoll = (pollType, pollId, answers = [], question, isMultipleResponse = false) => {
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('openPanel', 'poll');
|
|
|
|
Session.setItem('forcePollOpen', true);
|
2023-12-11 21:31:13 +08:00
|
|
|
window.dispatchEvent(new Event('panelChanged'));
|
|
|
|
|
|
|
|
createPoll({
|
|
|
|
variables: {
|
|
|
|
pollType,
|
|
|
|
pollId: `${pollId}/${new Date().getTime()}`,
|
|
|
|
secretPoll: false,
|
|
|
|
question,
|
|
|
|
isMultipleResponse,
|
|
|
|
answers,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-05-16 22:43:23 +08:00
|
|
|
const isPollingEnabled = useIsPollingEnabled();
|
2024-07-07 01:36:21 +08:00
|
|
|
const meetingIsBreakout = useMeetingIsBreakout();
|
2024-07-08 21:18:26 +08:00
|
|
|
const allowInfiniteWhiteboard = useIsInfiniteWhiteboardEnabled();
|
2024-05-16 22:43:23 +08:00
|
|
|
|
2019-08-14 01:41:47 +08:00
|
|
|
if (userIsPresenter && !layoutSwapped) {
|
2018-12-12 00:28:37 +08:00
|
|
|
// Only show controls if user is presenter and layout isn't swapped
|
|
|
|
|
2023-11-29 02:31:28 +08:00
|
|
|
const pluginProvidedPresentationToolbarItems = pluginsExtensibleAreasAggregatedState
|
2023-08-16 06:31:11 +08:00
|
|
|
?.presentationToolbarItems;
|
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
return (
|
|
|
|
<PresentationToolbar
|
2019-07-18 08:30:28 +08:00
|
|
|
{...props}
|
2021-11-24 00:04:45 +08:00
|
|
|
amIPresenter={userIsPresenter}
|
2023-03-16 02:06:59 +08:00
|
|
|
endCurrentPoll={endCurrentPoll}
|
2024-05-16 22:43:23 +08:00
|
|
|
isPollingEnabled={isPollingEnabled}
|
2024-07-07 01:36:21 +08:00
|
|
|
allowInfiniteWhiteboardInBreakouts={WHITEBOARD_CONFIG?.allowInfiniteWhiteboardInBreakouts}
|
2024-07-08 21:18:26 +08:00
|
|
|
allowInfiniteWhiteboard={allowInfiniteWhiteboard}
|
2024-05-16 22:43:23 +08:00
|
|
|
// TODO: Remove this
|
|
|
|
isMeteorConnected
|
2022-02-04 21:57:54 +08:00
|
|
|
{...{
|
2023-08-16 06:31:11 +08:00
|
|
|
pluginProvidedPresentationToolbarItems,
|
2022-02-04 21:57:54 +08:00
|
|
|
handleToggleFullScreen,
|
2023-12-11 21:31:13 +08:00
|
|
|
startPoll,
|
2024-01-20 22:01:20 +08:00
|
|
|
previousSlide,
|
|
|
|
nextSlide,
|
|
|
|
skipToSlide,
|
2024-07-06 04:09:19 +08:00
|
|
|
setPresentationPageInfiniteWhiteboard,
|
2024-06-14 21:58:32 +08:00
|
|
|
currentSlide,
|
|
|
|
currentPresentationPage,
|
2024-07-06 04:09:19 +08:00
|
|
|
infiniteWhiteboardIcon,
|
2024-07-04 01:05:06 +08:00
|
|
|
resetSlide,
|
2024-07-07 01:36:21 +08:00
|
|
|
meetingIsBreakout,
|
2022-02-04 21:57:54 +08:00
|
|
|
}}
|
2017-08-21 08:16:39 +08:00
|
|
|
/>
|
|
|
|
);
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
2017-08-21 08:16:39 +08:00
|
|
|
return null;
|
|
|
|
};
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2024-05-16 22:43:23 +08:00
|
|
|
export default PresentationToolbarContainer;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
PresentationToolbarContainer.propTypes = {
|
|
|
|
// Number of current slide being displayed
|
|
|
|
currentSlideNum: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// Total number of slides in this presentation
|
|
|
|
numberOfSlides: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// Actions required for the presenter toolbar
|
2023-03-10 19:30:46 +08:00
|
|
|
layoutSwapped: PropTypes.bool,
|
|
|
|
};
|