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';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2021-06-12 00:55:53 +08:00
|
|
|
import PollService from '/imports/ui/components/poll/service';
|
2020-01-11 04:18:43 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2017-08-21 08:16:39 +08:00
|
|
|
import PresentationToolbar from './component';
|
2019-02-14 20:03:25 +08:00
|
|
|
import PresentationToolbarService from './service';
|
2021-11-23 21:40:23 +08:00
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2022-02-15 22:42:02 +08:00
|
|
|
import FullscreenService from '/imports/ui/components/common/fullscreen-button/service';
|
2022-03-09 02:05:24 +08:00
|
|
|
import { isPollingEnabled } from '/imports/ui/services/features';
|
2023-03-16 02:06:59 +08:00
|
|
|
import { CurrentPoll } from '/imports/api/polls';
|
2023-08-16 06:31:11 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2020-01-11 03:00:06 +08:00
|
|
|
|
2017-09-26 07:45:44 +08:00
|
|
|
const PresentationToolbarContainer = (props) => {
|
2021-11-23 21:40:23 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
2023-08-16 06:31:11 +08:00
|
|
|
const pluginsContext = useContext(PluginsContext);
|
2021-11-23 21:40:23 +08:00
|
|
|
const { users } = usingUsersContext;
|
2023-08-16 06:31:11 +08:00
|
|
|
const { pluginsProvidedAggregatedState } = pluginsContext;
|
2021-11-23 21:40:23 +08:00
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
|
|
|
const userIsPresenter = currentUser.presenter;
|
|
|
|
|
|
|
|
const { layoutSwapped } = props;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2022-02-04 21:57:54 +08:00
|
|
|
const handleToggleFullScreen = (ref) => FullscreenService.toggleFullScreen(ref);
|
|
|
|
|
2023-03-16 02:06:59 +08:00
|
|
|
const endCurrentPoll = () => {
|
|
|
|
if (CurrentPoll.findOne({ meetingId: Auth.meetingID })) makeCall('stopPoll');
|
2023-03-16 02:24:34 +08:00
|
|
|
};
|
2023-03-16 02:06:59 +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-08-16 06:31:11 +08:00
|
|
|
const pluginProvidedPresentationToolbarItems = pluginsProvidedAggregatedState
|
|
|
|
?.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}
|
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,
|
|
|
|
}}
|
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
|
|
|
|
2023-10-11 22:21:35 +08:00
|
|
|
export default withTracker(() => {
|
2022-10-13 01:34:40 +08:00
|
|
|
const startPoll = (type, id, answers = [], question = '', multiResp = false) => {
|
2020-01-11 04:18:43 +08:00
|
|
|
Session.set('openPanel', 'poll');
|
|
|
|
Session.set('forcePollOpen', true);
|
2021-04-07 22:44:37 +08:00
|
|
|
window.dispatchEvent(new Event('panelChanged'));
|
2020-01-11 04:18:43 +08:00
|
|
|
|
2022-10-13 01:34:40 +08:00
|
|
|
makeCall('startPoll', PollService.pollTypes, type, id, false, question, multiResp, answers);
|
2020-01-11 04:18:43 +08:00
|
|
|
};
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
return {
|
2019-07-18 08:30:28 +08:00
|
|
|
nextSlide: PresentationToolbarService.nextSlide,
|
|
|
|
previousSlide: PresentationToolbarService.previousSlide,
|
|
|
|
skipToSlide: PresentationToolbarService.skipToSlide,
|
2019-06-27 00:29:34 +08:00
|
|
|
isMeteorConnected: Meteor.status().connected,
|
2022-03-09 02:05:24 +08:00
|
|
|
isPollingEnabled: isPollingEnabled(),
|
2020-01-11 04:18:43 +08:00
|
|
|
startPoll,
|
2016-08-06 02:39:24 +08:00
|
|
|
};
|
2018-01-08 12:44:42 +08:00
|
|
|
})(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,
|
2018-08-23 01:49:33 +08:00
|
|
|
zoom: PropTypes.number.isRequired,
|
|
|
|
zoomChanger: PropTypes.func.isRequired,
|
2017-08-21 08:16:39 +08:00
|
|
|
|
|
|
|
// Total number of slides in this presentation
|
|
|
|
numberOfSlides: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// Actions required for the presenter toolbar
|
2019-07-18 08:30:28 +08:00
|
|
|
nextSlide: PropTypes.func.isRequired,
|
|
|
|
previousSlide: PropTypes.func.isRequired,
|
|
|
|
skipToSlide: PropTypes.func.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
layoutSwapped: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
PresentationToolbarContainer.defaultProps = {
|
|
|
|
layoutSwapped: false,
|
2017-08-21 08:16:39 +08:00
|
|
|
};
|