2021-04-07 03:58:11 +08:00
|
|
|
import React, { useContext } from 'react';
|
2023-03-10 19:30:46 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2019-05-10 01:44:54 +08:00
|
|
|
import { notify } from '/imports/ui/services/notification';
|
2021-06-09 21:49:59 +08:00
|
|
|
import PresentationService from './service';
|
2020-04-08 05:19:16 +08:00
|
|
|
import { Slides } from '/imports/api/slides';
|
2021-06-09 21:49:59 +08:00
|
|
|
import Presentation from '/imports/ui/components/presentation/component';
|
2019-07-18 08:30:28 +08:00
|
|
|
import PresentationToolbarService from './presentation-toolbar/service';
|
2021-04-07 03:58:11 +08:00
|
|
|
import { UsersContext } from '../components-data/users-context/context';
|
2020-05-12 20:58:14 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2020-05-12 20:58:14 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2021-09-11 04:48:52 +08:00
|
|
|
import {
|
|
|
|
layoutSelect,
|
|
|
|
layoutSelectInput,
|
|
|
|
layoutSelectOutput,
|
|
|
|
layoutDispatch,
|
|
|
|
} from '../layout/context';
|
2023-03-10 19:30:46 +08:00
|
|
|
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
|
2021-03-05 06:26:25 +08:00
|
|
|
import WhiteboardService from '/imports/ui/components/whiteboard/service';
|
2021-08-04 19:42:38 +08:00
|
|
|
import { DEVICE_TYPE } from '../layout/enums';
|
2023-01-24 21:05:49 +08:00
|
|
|
import MediaService from '../media/service';
|
2020-05-12 20:58:14 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const PresentationContainer = ({
|
2023-06-29 03:06:19 +08:00
|
|
|
presentationIsOpen, presentationPodIds, mountPresentation, layoutType, ...props
|
2023-03-10 19:30:46 +08:00
|
|
|
}) => {
|
2021-09-11 04:48:52 +08:00
|
|
|
const cameraDock = layoutSelectInput((i) => i.cameraDock);
|
|
|
|
const presentation = layoutSelectOutput((i) => i.presentation);
|
|
|
|
const fullscreen = layoutSelect((i) => i.fullscreen);
|
|
|
|
const deviceType = layoutSelect((i) => i.deviceType);
|
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-08-05 15:26:03 +08:00
|
|
|
const { numCameras } = cameraDock;
|
2021-07-13 03:47:06 +08:00
|
|
|
const { element } = fullscreen;
|
2021-09-10 21:16:44 +08:00
|
|
|
const fullscreenElementId = 'Presentation';
|
2021-07-06 19:28:17 +08:00
|
|
|
const fullscreenContext = (element === fullscreenElementId);
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-08-28 02:32:56 +08:00
|
|
|
const isIphone = !!(navigator.userAgent.match(/iPhone/i));
|
2021-04-20 01:54:14 +08:00
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
2021-04-15 20:12:21 +08:00
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
2021-11-23 21:31:01 +08:00
|
|
|
const userIsPresenter = currentUser.presenter;
|
2021-04-20 01:54:14 +08:00
|
|
|
|
2021-08-24 05:04:16 +08:00
|
|
|
return (
|
|
|
|
<Presentation
|
|
|
|
{
|
|
|
|
...{
|
|
|
|
layoutContextDispatch,
|
|
|
|
numCameras,
|
|
|
|
...props,
|
2022-02-10 03:45:43 +08:00
|
|
|
userIsPresenter,
|
2021-08-24 05:04:16 +08:00
|
|
|
presentationBounds: presentation,
|
|
|
|
layoutType,
|
|
|
|
fullscreenContext,
|
|
|
|
fullscreenElementId,
|
2021-08-28 02:37:19 +08:00
|
|
|
isMobile: deviceType === DEVICE_TYPE.MOBILE,
|
|
|
|
isIphone,
|
2022-02-11 22:30:35 +08:00
|
|
|
presentationIsOpen,
|
2021-08-24 05:04:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
2021-04-07 03:58:11 +08:00
|
|
|
};
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2020-04-08 05:19:16 +08:00
|
|
|
const APP_CONFIG = Meteor.settings.public.app;
|
|
|
|
const PRELOAD_NEXT_SLIDE = APP_CONFIG.preloadNextSlides;
|
|
|
|
const fetchedpresentation = {};
|
2020-04-14 01:43:35 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
export default lockContextContainer(
|
2022-06-02 23:00:28 +08:00
|
|
|
withTracker(({ podId, presentationIsOpen, userLocks }) => {
|
2023-03-10 19:30:46 +08:00
|
|
|
const currentSlide = PresentationService.getCurrentSlide(podId);
|
2023-04-05 23:37:56 +08:00
|
|
|
const numPages = PresentationService.getSlidesLength(podId);
|
2023-03-10 19:30:46 +08:00
|
|
|
const presentationIsDownloadable = PresentationService.isPresentationDownloadable(podId);
|
|
|
|
const isViewersCursorLocked = userLocks?.hideViewersCursor;
|
2023-06-06 04:02:06 +08:00
|
|
|
const isViewersAnnotationsLocked = userLocks?.hideViewersAnnotation;
|
2020-04-14 01:43:35 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
let slidePosition;
|
|
|
|
if (currentSlide) {
|
|
|
|
const {
|
2020-04-08 05:19:16 +08:00
|
|
|
presentationId,
|
2023-03-10 19:30:46 +08:00
|
|
|
id: slideId,
|
|
|
|
} = currentSlide;
|
|
|
|
slidePosition = PresentationService.getSlidePosition(podId, presentationId, slideId);
|
|
|
|
if (PRELOAD_NEXT_SLIDE && !fetchedpresentation[presentationId]) {
|
|
|
|
fetchedpresentation[presentationId] = {
|
|
|
|
canFetch: true,
|
|
|
|
fetchedSlide: {},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const currentSlideNum = currentSlide.num;
|
|
|
|
const presentation = fetchedpresentation[presentationId];
|
2020-04-08 05:19:16 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
if (PRELOAD_NEXT_SLIDE
|
|
|
|
&& !presentation.fetchedSlide[currentSlide.num + PRELOAD_NEXT_SLIDE]
|
|
|
|
&& presentation.canFetch) {
|
|
|
|
const slidesToFetch = Slides.find({
|
|
|
|
podId,
|
|
|
|
presentationId,
|
|
|
|
num: {
|
|
|
|
$in: Array(PRELOAD_NEXT_SLIDE).fill(1).map((v, idx) => currentSlideNum + (idx + 1)),
|
|
|
|
},
|
|
|
|
}).fetch();
|
|
|
|
|
|
|
|
const promiseImageGet = slidesToFetch
|
|
|
|
.filter((s) => !fetchedpresentation[presentationId].fetchedSlide[s.num])
|
|
|
|
.map(async (slide) => {
|
|
|
|
if (presentation.canFetch) presentation.canFetch = false;
|
|
|
|
const image = await fetch(slide.imageUri);
|
|
|
|
if (image.ok) {
|
|
|
|
presentation.fetchedSlide[slide.num] = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Promise.all(promiseImageGet).then(() => {
|
|
|
|
presentation.canFetch = true;
|
2020-04-08 05:19:16 +08:00
|
|
|
});
|
2023-03-10 19:30:46 +08:00
|
|
|
}
|
2020-04-08 05:19:16 +08:00
|
|
|
}
|
2023-04-13 21:56:54 +08:00
|
|
|
const currentPresentation = PresentationService.getCurrentPresentation(podId);
|
2024-03-04 21:26:50 +08:00
|
|
|
|
|
|
|
const downloadPresentationUri = currentPresentation
|
|
|
|
? `${APP_CONFIG.bbbWebBase}/${currentPresentation?.originalFileURI}`
|
|
|
|
: null;
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
return {
|
|
|
|
currentSlide,
|
|
|
|
slidePosition,
|
2024-03-04 21:26:50 +08:00
|
|
|
downloadPresentationUri,
|
2023-03-10 19:30:46 +08:00
|
|
|
multiUser:
|
|
|
|
(WhiteboardService.hasMultiUserAccess(currentSlide && currentSlide.id, Auth.userID)
|
|
|
|
|| WhiteboardService.isMultiUserActive(currentSlide?.id)
|
|
|
|
) && presentationIsOpen,
|
|
|
|
presentationIsDownloadable,
|
|
|
|
mountPresentation: !!currentSlide,
|
2023-04-13 21:56:54 +08:00
|
|
|
currentPresentation,
|
2023-04-14 02:25:31 +08:00
|
|
|
currentPresentationId: currentPresentation?.id,
|
2023-04-05 23:37:56 +08:00
|
|
|
numPages,
|
2023-03-10 19:30:46 +08:00
|
|
|
notify,
|
|
|
|
zoomSlide: PresentationToolbarService.zoomSlide,
|
|
|
|
podId,
|
|
|
|
publishedPoll: Meetings.findOne({ meetingId: Auth.meetingID }, {
|
|
|
|
fields: {
|
|
|
|
publishedPoll: 1,
|
|
|
|
},
|
|
|
|
}).publishedPoll,
|
|
|
|
restoreOnUpdate: getFromUserSettings(
|
|
|
|
'bbb_force_restore_presentation_on_new_events',
|
|
|
|
Meteor.settings.public.presentation.restoreOnUpdate,
|
|
|
|
),
|
|
|
|
addWhiteboardGlobalAccess: WhiteboardService.addGlobalAccess,
|
|
|
|
removeWhiteboardGlobalAccess: WhiteboardService.removeGlobalAccess,
|
|
|
|
multiUserSize: WhiteboardService.getMultiUserSize(currentSlide?.id),
|
|
|
|
isViewersCursorLocked,
|
|
|
|
setPresentationIsOpen: MediaService.setPresentationIsOpen,
|
2023-06-06 04:02:06 +08:00
|
|
|
isViewersAnnotationsLocked,
|
2023-03-10 19:30:46 +08:00
|
|
|
};
|
|
|
|
})(PresentationContainer),
|
|
|
|
);
|
|
|
|
|
|
|
|
PresentationContainer.propTypes = {
|
|
|
|
presentationPodIds: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
podId: PropTypes.string.isRequired,
|
|
|
|
})).isRequired,
|
|
|
|
presentationIsOpen: PropTypes.bool.isRequired,
|
|
|
|
mountPresentation: PropTypes.bool.isRequired,
|
|
|
|
};
|