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

96 lines
3.3 KiB
React
Raw Normal View History

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
import PollService from '/imports/ui/components/poll/service';
import { makeCall } from '/imports/ui/services/api';
import PresentationToolbar from './component';
import PresentationToolbarService from './service';
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
import Auth from '/imports/ui/services/auth';
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';
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
const PresentationToolbarContainer = (props) => {
const usingUsersContext = useContext(UsersContext);
const pluginsContext = useContext(PluginsContext);
const { users } = usingUsersContext;
const { pluginsProvidedAggregatedState } = pluginsContext;
const currentUser = users[Auth.meetingID][Auth.userID];
const userIsPresenter = currentUser.presenter;
const { layoutSwapped } = props;
2016-08-03 06:55:20 +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
if (userIsPresenter && !layoutSwapped) {
// Only show controls if user is presenter and layout isn't swapped
const pluginProvidedPresentationToolbarItems = pluginsProvidedAggregatedState
?.presentationToolbarItems;
return (
<PresentationToolbar
{...props}
2021-11-24 00:04:45 +08:00
amIPresenter={userIsPresenter}
2023-03-16 02:06:59 +08:00
endCurrentPoll={endCurrentPoll}
{...{
pluginProvidedPresentationToolbarItems,
handleToggleFullScreen,
}}
/>
);
2016-08-03 06:55:20 +08:00
}
return null;
};
2016-08-03 06:55:20 +08:00
export default withTracker((params) => {
const {
podId,
presentationId,
} = params;
2016-08-06 02:39:24 +08:00
const startPoll = (type, id, answers = [], question = '', multiResp = false) => {
Session.set('openPanel', 'poll');
Session.set('forcePollOpen', true);
2021-04-07 22:44:37 +08:00
window.dispatchEvent(new Event('panelChanged'));
makeCall('startPoll', PollService.pollTypes, type, id, false, question, multiResp, answers);
};
2016-08-06 02:39:24 +08:00
return {
numberOfSlides: PresentationToolbarService.getNumberOfSlides(podId, presentationId),
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(),
startPoll,
2016-08-06 02:39:24 +08:00
};
})(PresentationToolbarContainer);
2016-08-03 06:55:20 +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,
// Total number of slides in this presentation
numberOfSlides: PropTypes.number.isRequired,
// Actions required for the presenter toolbar
nextSlide: PropTypes.func.isRequired,
previousSlide: PropTypes.func.isRequired,
skipToSlide: PropTypes.func.isRequired,
layoutSwapped: PropTypes.bool,
};
PresentationToolbarContainer.defaultProps = {
layoutSwapped: false,
};