From 4806e001925aa1151bdf4ea328426a4465ee6087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Fri, 8 Dec 2023 17:24:57 -0300 Subject: [PATCH] migrate stopPoll meteor call --- .../imports/api/polls/server/methods.js | 2 -- .../api/polls/server/methods/stopPoll.js | 21 ------------------- .../quick-poll-dropdown/container.jsx | 9 +++++--- .../imports/ui/components/poll/container.jsx | 8 +++---- .../imports/ui/components/poll/mutations.jsx | 7 +++++++ .../presentation-toolbar/container.jsx | 7 +++++-- .../presentation-uploader/service.js | 3 --- 7 files changed, 21 insertions(+), 36 deletions(-) delete mode 100644 bigbluebutton-html5/imports/api/polls/server/methods/stopPoll.js diff --git a/bigbluebutton-html5/imports/api/polls/server/methods.js b/bigbluebutton-html5/imports/api/polls/server/methods.js index 3483621cd0..9b269ad7d9 100644 --- a/bigbluebutton-html5/imports/api/polls/server/methods.js +++ b/bigbluebutton-html5/imports/api/polls/server/methods.js @@ -1,8 +1,6 @@ import { Meteor } from 'meteor/meteor'; import startPoll from './methods/startPoll'; -import stopPoll from './methods/stopPoll'; Meteor.methods({ startPoll, - stopPoll, }); diff --git a/bigbluebutton-html5/imports/api/polls/server/methods/stopPoll.js b/bigbluebutton-html5/imports/api/polls/server/methods/stopPoll.js deleted file mode 100644 index 7853a7bc2c..0000000000 --- a/bigbluebutton-html5/imports/api/polls/server/methods/stopPoll.js +++ /dev/null @@ -1,21 +0,0 @@ -import RedisPubSub from '/imports/startup/server/redis'; -import { extractCredentials } from '/imports/api/common/server/helpers'; -import { check } from 'meteor/check'; -import Logger from '/imports/startup/server/logger'; - -export default function stopPoll() { - const REDIS_CONFIG = Meteor.settings.private.redis; - const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; - const EVENT_NAME = 'StopPollReqMsg'; - - try { - const { meetingId, requesterUserId: requesterId } = extractCredentials(this.userId); - - check(meetingId, String); - check(requesterId, String); - - RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterId, ({ requesterId })); - } catch (err) { - Logger.error(`Exception while invoking method stopPoll ${err.stack}`); - } -} diff --git a/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/container.jsx b/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/container.jsx index 7c19722424..7f21c9db4c 100644 --- a/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/container.jsx @@ -1,18 +1,21 @@ import React from 'react'; import { withTracker } from 'meteor/react-meteor-data'; import { injectIntl } from 'react-intl'; -import { makeCall } from '/imports/ui/services/api'; import PollService from '/imports/ui/components/poll/service'; import QuickPollDropdown from './component'; +import { useMutation } from '@apollo/client'; import { layoutDispatch } from '../../layout/context'; +import { POLL_CANCEL } from '/imports/ui/components/poll/mutations'; const QuickPollDropdownContainer = (props) => { const layoutContextDispatch = layoutDispatch(); - return ; + + const [stopPoll] = useMutation(POLL_CANCEL); + + return ; }; export default withTracker(() => ({ activePoll: Session.get('pollInitiated') || false, pollTypes: PollService.pollTypes, - stopPoll: () => makeCall('stopPoll'), }))(injectIntl(QuickPollDropdownContainer)); diff --git a/bigbluebutton-html5/imports/ui/components/poll/container.jsx b/bigbluebutton-html5/imports/ui/components/poll/container.jsx index 0fc58d127a..0fee9a1cc2 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/container.jsx @@ -8,7 +8,7 @@ import Service from './service'; import Auth from '/imports/ui/services/auth'; import { UsersContext } from '../components-data/users-context/context'; import { layoutDispatch, layoutSelectInput } from '../layout/context'; -import { POLL_PUBLISH_RESULT } from './mutations'; +import { POLL_PUBLISH_RESULT, POLL_CANCEL } from './mutations'; const CHAT_CONFIG = Meteor.settings.public.chat; const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id; @@ -28,6 +28,7 @@ const PollContainer = ({ ...props }) => { }); const [pollPublishResult] = useMutation(POLL_PUBLISH_RESULT); + const [stopPoll] = useMutation(POLL_CANCEL); const publishPoll = (pollId) => { pollPublishResult({ @@ -39,7 +40,7 @@ const PollContainer = ({ ...props }) => { return ( ); @@ -58,15 +59,12 @@ export default withTracker(({ amIPresenter, currentSlideId }) => { const startCustomPoll = (type, secretPoll, question = '', isMultipleResponse, answers) => makeCall('startPoll', pollTypes, type, pollId, secretPoll, question, isMultipleResponse, answers); - const stopPoll = () => makeCall('stopPoll'); - return { isPollSecret, currentSlideId, pollTypes, startPoll, startCustomPoll, - stopPoll, currentPoll: Service.currentPoll(), isDefaultPoll: Service.isDefaultPoll, checkPollType: Service.checkPollType, diff --git a/bigbluebutton-html5/imports/ui/components/poll/mutations.jsx b/bigbluebutton-html5/imports/ui/components/poll/mutations.jsx index 08bcf97d84..d8b3279561 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/mutations.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/mutations.jsx @@ -26,8 +26,15 @@ export const POLL_SUBMIT_VOTE = gql` } `; +export const POLL_CANCEL = gql` + mutation PollCancel { + pollCancel + } +`; + export default { POLL_PUBLISH_RESULT, POLL_SUBMIT_TYPED_VOTE, POLL_SUBMIT_VOTE, + POLL_CANCEL, }; diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx index 1518f643f8..3938c34160 100755 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx @@ -8,8 +8,9 @@ import PresentationToolbarService from './service'; import FullscreenService from '/imports/ui/components/common/fullscreen-button/service'; import { isPollingEnabled } from '/imports/ui/services/features'; import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context'; -import { useSubscription } from '@apollo/client'; +import { useSubscription, useMutation } from '@apollo/client'; import POLL_SUBSCRIPTION from '/imports/ui/core/graphql/queries/pollSubscription'; +import { POLL_CANCEL } from '/imports/ui/components/poll/mutations'; const PresentationToolbarContainer = (props) => { const pluginsContext = useContext(PluginsContext); @@ -22,8 +23,10 @@ const PresentationToolbarContainer = (props) => { const handleToggleFullScreen = (ref) => FullscreenService.toggleFullScreen(ref); + const [stopPoll] = useMutation(POLL_CANCEL); + const endCurrentPoll = () => { - if (hasPoll) makeCall('stopPoll'); + if (hasPoll) stopPoll(); }; if (userIsPresenter && !layoutSwapped) { 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 3b4f1bea24..ac1188285a 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js @@ -1,7 +1,6 @@ import { UploadingPresentations } from '/imports/api/presentations'; import PresentationUploadToken from '/imports/api/presentation-upload-token'; import Auth from '/imports/ui/services/auth'; -import Poll from '/imports/api/polls/'; import { Meteor } from 'meteor/meteor'; import { makeCall } from '/imports/ui/services/api'; import logger from '/imports/startup/client/logger'; @@ -189,8 +188,6 @@ const setPresentation = (presentationId) => { }; const removePresentation = (presentationId) => { - const hasPoll = Poll.find({}, { fields: {} }).count(); - if (hasPoll) makeCall('stopPoll'); makeCall('removePresentation', presentationId, POD_ID); };