2023-11-30 19:08:16 +08:00
|
|
|
import React from 'react';
|
2022-02-15 22:11:03 +08:00
|
|
|
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component';
|
2022-02-15 22:29:38 +08:00
|
|
|
import FallbackModal from '/imports/ui/components/common/fallback-errors/fallback-modal/component';
|
2024-06-04 21:40:54 +08:00
|
|
|
import { useMutation } from '@apollo/client';
|
2017-05-04 00:36:16 +08:00
|
|
|
import Service from './service';
|
2022-09-23 23:24:39 +08:00
|
|
|
import PresUploaderToast from '/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component';
|
2017-05-04 00:36:16 +08:00
|
|
|
import PresentationUploader from './component';
|
2023-08-01 04:03:29 +08:00
|
|
|
import {
|
2024-06-12 23:16:00 +08:00
|
|
|
useIsPresentationEnabled,
|
|
|
|
useIsDownloadPresentationOriginalFileEnabled,
|
|
|
|
useIsDownloadPresentationConvertedToPdfEnabled,
|
|
|
|
useIsDownloadPresentationWithAnnotationsEnabled,
|
2023-08-01 04:03:29 +08:00
|
|
|
} from '/imports/ui/services/features';
|
2023-10-17 03:27:22 +08:00
|
|
|
import {
|
|
|
|
PRESENTATIONS_SUBSCRIPTION,
|
|
|
|
} from '/imports/ui/components/whiteboard/queries';
|
2023-11-30 19:08:16 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-01-26 20:55:55 +08:00
|
|
|
import {
|
|
|
|
PRESENTATION_SET_DOWNLOADABLE,
|
|
|
|
PRESENTATION_EXPORT,
|
|
|
|
PRESENTATION_SET_CURRENT,
|
|
|
|
PRESENTATION_REMOVE,
|
|
|
|
} from '../mutations';
|
2024-06-06 21:50:03 +08:00
|
|
|
import { useStorageKey } from '/imports/ui/services/storage/hooks';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
|
2020-02-26 03:29:14 +08:00
|
|
|
|
2021-11-23 22:12:00 +08:00
|
|
|
const PresentationUploaderContainer = (props) => {
|
2023-11-30 19:08:16 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
presenter: user.presenter,
|
|
|
|
}));
|
|
|
|
const userIsPresenter = currentUserData?.presenter;
|
2021-11-23 22:12:00 +08:00
|
|
|
|
2024-06-04 21:40:54 +08:00
|
|
|
const { data: presentationData } = useDeduplicatedSubscription(PRESENTATIONS_SUBSCRIPTION);
|
2023-10-17 03:27:22 +08:00
|
|
|
const presentations = presentationData?.pres_presentation || [];
|
|
|
|
const currentPresentation = presentations.find((p) => p.current)?.presentationId || '';
|
|
|
|
|
2024-01-20 22:43:34 +08:00
|
|
|
const [presentationSetDownloadable] = useMutation(PRESENTATION_SET_DOWNLOADABLE);
|
2024-01-26 20:55:55 +08:00
|
|
|
const [presentationExport] = useMutation(PRESENTATION_EXPORT);
|
2024-01-23 20:51:14 +08:00
|
|
|
const [presentationSetCurrent] = useMutation(PRESENTATION_SET_CURRENT);
|
2024-01-23 21:55:40 +08:00
|
|
|
const [presentationRemove] = useMutation(PRESENTATION_REMOVE);
|
2024-01-20 22:43:34 +08:00
|
|
|
|
2023-10-20 02:56:13 +08:00
|
|
|
const exportPresentation = (presentationId, fileStateType) => {
|
2024-01-26 20:55:55 +08:00
|
|
|
presentationExport({
|
2024-01-20 22:43:34 +08:00
|
|
|
variables: {
|
|
|
|
presentationId,
|
|
|
|
fileStateType,
|
|
|
|
},
|
|
|
|
});
|
2023-10-20 02:56:13 +08:00
|
|
|
};
|
|
|
|
|
2024-01-23 01:47:46 +08:00
|
|
|
const dispatchChangePresentationDownloadable = (presentationId, downloadable, fileStateType) => {
|
|
|
|
presentationSetDownloadable({
|
|
|
|
variables: {
|
|
|
|
presentationId,
|
|
|
|
downloadable,
|
|
|
|
fileStateType,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2024-01-23 20:51:14 +08:00
|
|
|
const setPresentation = (presentationId) => {
|
|
|
|
presentationSetCurrent({ variables: { presentationId } });
|
|
|
|
};
|
|
|
|
|
2024-01-23 21:55:40 +08:00
|
|
|
const removePresentation = (presentationId) => {
|
|
|
|
presentationRemove({ variables: { presentationId } });
|
|
|
|
};
|
|
|
|
|
2024-06-12 23:16:00 +08:00
|
|
|
const presentationEnabled = useIsPresentationEnabled();
|
|
|
|
const allowDownloadOriginal = useIsDownloadPresentationOriginalFileEnabled();
|
|
|
|
const allowDownloadConverted = useIsDownloadPresentationConvertedToPdfEnabled();
|
|
|
|
const allowDownloadWithAnnotations = useIsDownloadPresentationWithAnnotationsEnabled();
|
|
|
|
const externalUploadData = Service.useExternalUploadData();
|
|
|
|
const PRESENTATION_CONFIG = window.meetingClientSettings.public.presentation;
|
2024-06-06 21:50:03 +08:00
|
|
|
const isOpen = (useStorageKey('showUploadPresentationView') || false) && presentationEnabled;
|
|
|
|
const selectedToBeNextCurrent = useStorageKey('selectedToBeNextCurrent') || null;
|
|
|
|
|
2021-11-23 22:12:00 +08:00
|
|
|
return userIsPresenter && (
|
2023-03-24 21:07:56 +08:00
|
|
|
<ErrorBoundary Fallback={FallbackModal}>
|
2023-10-17 03:27:22 +08:00
|
|
|
<PresentationUploader
|
|
|
|
isPresenter={userIsPresenter}
|
|
|
|
presentations={presentations}
|
|
|
|
currentPresentation={currentPresentation}
|
2023-10-20 02:56:13 +08:00
|
|
|
exportPresentation={exportPresentation}
|
2024-01-23 01:47:46 +08:00
|
|
|
dispatchChangePresentationDownloadable={dispatchChangePresentationDownloadable}
|
2024-01-23 20:51:14 +08:00
|
|
|
setPresentation={setPresentation}
|
2024-01-23 21:55:40 +08:00
|
|
|
removePresentation={removePresentation}
|
2024-06-06 21:50:03 +08:00
|
|
|
isOpen={isOpen}
|
|
|
|
selectedToBeNextCurrent={selectedToBeNextCurrent}
|
2024-06-12 23:16:00 +08:00
|
|
|
fileUploadConstraintsHint={PRESENTATION_CONFIG.fileUploadConstraintsHint}
|
|
|
|
fileSizeMax={PRESENTATION_CONFIG.mirroredFromBBBCore.uploadSizeMax}
|
|
|
|
filePagesMax={PRESENTATION_CONFIG.mirroredFromBBBCore.uploadPagesMax}
|
|
|
|
fileValidMimeTypes={PRESENTATION_CONFIG.uploadValidMimeTypes}
|
|
|
|
allowDownloadOriginal={allowDownloadOriginal}
|
|
|
|
allowDownloadConverted={allowDownloadConverted}
|
|
|
|
allowDownloadWithAnnotations={allowDownloadWithAnnotations}
|
|
|
|
presentationEnabled={presentationEnabled}
|
|
|
|
externalUploadData={externalUploadData}
|
|
|
|
handleSave={Service.handleSavePresentation}
|
|
|
|
handleDismissToast={PresUploaderToast.handleDismissToast}
|
|
|
|
renderToastList={Service.renderToastList}
|
|
|
|
renderPresentationItemStatus={PresUploaderToast.renderPresentationItemStatus}
|
|
|
|
handleFiledrop={Service.handleFiledrop}
|
|
|
|
dispatchDisableDownloadable={Service.dispatchDisableDownloadable}
|
|
|
|
dispatchEnableDownloadable={Service.dispatchEnableDownloadable}
|
2023-10-17 03:27:22 +08:00
|
|
|
{...props}
|
|
|
|
/>
|
2021-06-12 03:33:15 +08:00
|
|
|
</ErrorBoundary>
|
2021-11-23 22:12:00 +08:00
|
|
|
);
|
|
|
|
};
|
2017-05-04 00:36:16 +08:00
|
|
|
|
2024-06-12 23:16:00 +08:00
|
|
|
export default PresentationUploaderContainer;
|