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

81 lines
2.8 KiB
React
Raw Normal View History

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
2018-08-23 01:49:33 +08:00
import PresentationService from '/imports/ui/components/presentation/service';
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';
const PresentationToolbarContainer = (props) => {
const usingUsersContext = useContext(UsersContext);
const { users } = usingUsersContext;
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);
if (userIsPresenter && !layoutSwapped) {
// Only show controls if user is presenter and layout isn't swapped
return (
<PresentationToolbar
{...props}
2021-11-24 00:04:45 +08:00
amIPresenter={userIsPresenter}
{...{
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(),
currentSlidHasContent: PresentationService.currentSlidHasContent(),
parseCurrentSlideContent: PresentationService.parseCurrentSlideContent,
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,
};