From 0dcb2bc7a2d0fdf6ce2778794483d991cb096e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Tue, 23 Jan 2024 10:55:40 -0300 Subject: [PATCH] migrate removePresentation action --- .../imports/api/presentations/server/index.js | 1 - .../api/presentations/server/methods.js | 6 ---- .../server/methods/removePresentation.js | 28 ------------------- .../notes/notes-dropdown/component.jsx | 3 +- .../notes/notes-dropdown/container.jsx | 21 ++++++++++++-- .../notes/notes-dropdown/service.js | 6 ++-- .../ui/components/presentation/mutations.jsx | 9 ++++++ .../presentation-uploader/component.jsx | 10 ++++++- .../presentation-uploader/container.jsx | 8 +++++- .../presentation-uploader/service.js | 23 +++++++++------ bigbluebutton-html5/server/main.js | 1 - 11 files changed, 64 insertions(+), 52 deletions(-) delete mode 100644 bigbluebutton-html5/imports/api/presentations/server/index.js delete mode 100644 bigbluebutton-html5/imports/api/presentations/server/methods.js delete mode 100644 bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js diff --git a/bigbluebutton-html5/imports/api/presentations/server/index.js b/bigbluebutton-html5/imports/api/presentations/server/index.js deleted file mode 100644 index ba55c4a16e..0000000000 --- a/bigbluebutton-html5/imports/api/presentations/server/index.js +++ /dev/null @@ -1 +0,0 @@ -import './methods'; diff --git a/bigbluebutton-html5/imports/api/presentations/server/methods.js b/bigbluebutton-html5/imports/api/presentations/server/methods.js deleted file mode 100644 index 1134b35779..0000000000 --- a/bigbluebutton-html5/imports/api/presentations/server/methods.js +++ /dev/null @@ -1,6 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import removePresentation from './methods/removePresentation'; - -Meteor.methods({ - removePresentation, -}); diff --git a/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js b/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js deleted file mode 100644 index 8a2ef1e898..0000000000 --- a/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js +++ /dev/null @@ -1,28 +0,0 @@ -import RedisPubSub from '/imports/startup/server/redis'; -import { check } from 'meteor/check'; -import { extractCredentials } from '/imports/api/common/server/helpers'; -import Logger from '/imports/startup/server/logger'; - -export default function removePresentation(presentationId, podId) { - const REDIS_CONFIG = Meteor.settings.private.redis; - const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; - const EVENT_NAME = 'RemovePresentationPubMsg'; - - try { - const { meetingId, requesterUserId } = extractCredentials(this.userId); - - check(meetingId, String); - check(requesterUserId, String); - check(presentationId, String); - check(podId, String); - - const payload = { - presentationId, - podId, - }; - - RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); - } catch (err) { - Logger.error(`Exception while invoking method removePresentation ${err.stack}`); - } -} diff --git a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/component.jsx b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/component.jsx index a836418d60..9e59a9987d 100644 --- a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/component.jsx @@ -52,6 +52,7 @@ class NotesDropdown extends PureComponent { amIPresenter, presentations, setPresentation, + removePresentation, } = this.props; const { converterButtonDisabled } = this.state; @@ -72,7 +73,7 @@ class NotesDropdown extends PureComponent { onClick: () => { this.setConverterButtonDisabled(true); setTimeout(() => this.setConverterButtonDisabled(false), DEBOUNCE_TIMEOUT); - return Service.convertAndUpload(presentations, setPresentation); + return Service.convertAndUpload(presentations, setPresentation, removePresentation); }, }, ); diff --git a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/container.jsx b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/container.jsx index 9e74d8c0dc..122d11e1cd 100644 --- a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/container.jsx @@ -6,7 +6,7 @@ import { PROCESSED_PRESENTATIONS_SUBSCRIPTION, } from '/imports/ui/components/whiteboard/queries'; import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser'; -import { PRESENTATION_SET_CURRENT } from '../../presentation/mutations'; +import { PRESENTATION_SET_CURRENT, PRESENTATION_REMOVE } from '../../presentation/mutations'; const NotesDropdownContainer = ({ ...props }) => { const { data: currentUserData } = useCurrentUser((user) => ({ @@ -19,12 +19,29 @@ const NotesDropdownContainer = ({ ...props }) => { const presentations = presentationData?.pres_presentation || []; const [presentationSetCurrent] = useMutation(PRESENTATION_SET_CURRENT); + const [presentationRemove] = useMutation(PRESENTATION_REMOVE); const setPresentation = (presentationId) => { presentationSetCurrent({ variables: { presentationId } }); }; - return ; + const removePresentation = (presentationId) => { + presentationRemove({ variables: { presentationId } }); + }; + + return ( + + ); }; export default NotesDropdownContainer; diff --git a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/service.js b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/service.js index a30b9ff057..c28f3089c4 100644 --- a/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/service.js +++ b/bigbluebutton-html5/imports/ui/components/notes/notes-dropdown/service.js @@ -7,7 +7,7 @@ import { uniqueId } from '/imports/utils/string-utils'; const PADS_CONFIG = Meteor.settings.public.pads; -async function convertAndUpload(presentations, setPresentation) { +async function convertAndUpload(presentations, setPresentation, removePresentation) { let filename = 'Shared_Notes'; const duplicates = presentations.filter((pres) => pres.filename?.startsWith(filename) || pres.name?.startsWith(filename)).length; @@ -52,7 +52,9 @@ async function convertAndUpload(presentations, setPresentation) { onUpload: () => { }, onProgress: () => { }, onDone: () => { }, - }, setPresentation); + }, + setPresentation, + removePresentation); } export default { diff --git a/bigbluebutton-html5/imports/ui/components/presentation/mutations.jsx b/bigbluebutton-html5/imports/ui/components/presentation/mutations.jsx index 3442b5ac8d..ee698aae4b 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/mutations.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/mutations.jsx @@ -53,10 +53,19 @@ export const PRESENTATION_SET_CURRENT = gql` } `; +export const PRESENTATION_REMOVE = gql` + mutation PresentationRemove($presentationId: String!) { + presentationRemove( + presentationId: $presentationId, + ) + } +`; + export default { PRESENTATION_SET_ZOOM, PRESENTATION_SET_WRITERS, PRESENTATION_SET_PAGE, PRESENTATION_SET_DOWNLOADABLE, PRESENTATION_SET_CURRENT, + PRESENTATION_REMOVE, }; diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx index 26d5859083..e09a061567 100755 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/component.jsx @@ -584,6 +584,7 @@ class PresentationUploader extends Component { presentations: propPresentations, dispatchChangePresentationDownloadable, setPresentation, + removePresentation, } = this.props; const { disableActions, presentations } = this.state; const presentationsToSave = presentations; @@ -611,7 +612,14 @@ class PresentationUploader extends Component { if (!disableActions) { Session.set('showUploadPresentationView', false); - return handleSave(presentationsToSave, true, {}, propPresentations, setPresentation) + return handleSave( + presentationsToSave, + true, + {}, + propPresentations, + setPresentation, + removePresentation, + ) .then(() => { const hasError = presentations.some((p) => !!p.uploadErrorMsgKey); if (!hasError) { diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx index 20867af21d..181f09cbf9 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx @@ -17,7 +17,7 @@ import { PRESENTATIONS_SUBSCRIPTION, } from '/imports/ui/components/whiteboard/queries'; import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser'; -import { PRESENTATION_SET_DOWNLOADABLE, PRESENTATION_SET_CURRENT } from '../mutations'; +import { PRESENTATION_SET_DOWNLOADABLE, PRESENTATION_SET_CURRENT, PRESENTATION_REMOVE } from '../mutations'; const PRESENTATION_CONFIG = Meteor.settings.public.presentation; @@ -33,6 +33,7 @@ const PresentationUploaderContainer = (props) => { const [presentationSetDownloadable] = useMutation(PRESENTATION_SET_DOWNLOADABLE); const [presentationSetCurrent] = useMutation(PRESENTATION_SET_CURRENT); + const [presentationRemove] = useMutation(PRESENTATION_REMOVE); const exportPresentation = (presentationId, fileStateType) => { presentationSetDownloadable({ @@ -58,6 +59,10 @@ const PresentationUploaderContainer = (props) => { presentationSetCurrent({ variables: { presentationId } }); }; + const removePresentation = (presentationId) => { + presentationRemove({ variables: { presentationId } }); + }; + return userIsPresenter && ( { exportPresentation={exportPresentation} dispatchChangePresentationDownloadable={dispatchChangePresentationDownloadable} setPresentation={setPresentation} + removePresentation={removePresentation} {...props} /> diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js index 944fbdb661..459740f021 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js @@ -179,15 +179,18 @@ const uploadAndConvertPresentations = ( p.onUpload, p.onProgress, p.onConversion, p.current, ))); -const removePresentation = (presentationId) => { - makeCall('removePresentation', presentationId, POD_ID); -}; - const removePresentations = ( presentationsToRemove, -) => Promise.all(presentationsToRemove.map((p) => removePresentation(p.presentationId, POD_ID))); + removePresentation, +) => Promise.all(presentationsToRemove.map((p) => removePresentation(p.presentationId))); -const persistPresentationChanges = (oldState, newState, uploadEndpoint, setPresentation) => { +const persistPresentationChanges = ( + oldState, + newState, + uploadEndpoint, + setPresentation, + removePresentation, +) => { const presentationsToUpload = newState.filter((p) => !p.uploadCompleted); const presentationsToRemove = oldState.filter((p) => !newState.find((u) => { return u.presentationId === p.presentationId })); @@ -206,7 +209,7 @@ const persistPresentationChanges = (oldState, newState, uploadEndpoint, setPrese }) .then((presentations) => { if (currentPresentation === undefined) { - setPresentation('', POD_ID); + setPresentation(''); return Promise.resolve(); } @@ -221,9 +224,9 @@ const persistPresentationChanges = (oldState, newState, uploadEndpoint, setPrese return Promise.resolve(); } - return setPresentation(currentPresentation?.presentationId, POD_ID); + return setPresentation(currentPresentation?.presentationId); }) - .then(removePresentations.bind(null, presentationsToRemove, POD_ID)); + .then(removePresentations.bind(null, presentationsToRemove, removePresentation)); }; const handleSavePresentation = ( @@ -232,6 +235,7 @@ const handleSavePresentation = ( newPres = {}, currentPresentations = [], setPresentation, + removePresentation, ) => { if (!isPresentationEnabled()) { return null; @@ -254,6 +258,7 @@ const handleSavePresentation = ( presentations, PRESENTATION_CONFIG.uploadEndpoint, setPresentation, + removePresentation, ); }; diff --git a/bigbluebutton-html5/server/main.js b/bigbluebutton-html5/server/main.js index 739d7f3c09..1a33749f2f 100755 --- a/bigbluebutton-html5/server/main.js +++ b/bigbluebutton-html5/server/main.js @@ -7,7 +7,6 @@ import '/imports/api/annotations/server'; import '/imports/api/cursor/server'; import '/imports/api/polls/server'; import '/imports/api/captions/server'; -import '/imports/api/presentations/server'; import '/imports/api/presentation-upload-token/server'; import '/imports/api/breakouts/server'; import '/imports/api/breakouts-history/server';