From 8da630da03ac59a04610190f2619829fea9fded2 Mon Sep 17 00:00:00 2001
From: Ramon Souza <contato@ramonsouza.com>
Date: Mon, 14 Jun 2021 09:55:18 -0300
Subject: [PATCH] fix presentation service isPresenter

---
 .../presentation-uploader/container.jsx         | 11 ++++-------
 .../ui/components/presentation/service.js       | 17 ++++++-----------
 2 files changed, 10 insertions(+), 18 deletions(-)

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 3ea7d6e4e4..b8d4421f5d 100644
--- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx
+++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/container.jsx
@@ -4,9 +4,8 @@ import { withTracker } from 'meteor/react-meteor-data';
 import ErrorBoundary from '/imports/ui/components/error-boundary/component';
 import FallbackModal from '/imports/ui/components/fallback-errors/fallback-modal/component';
 import Service from './service';
+import PresentationService from '../service';
 import PresentationUploader from './component';
-import { withUsersConsumer } from '/imports/ui/components/components-data/users-context/context';
-import Auth from '/imports/ui/services/auth';
 
 const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
 
@@ -19,7 +18,7 @@ const PresentationUploaderContainer = (props) => (
   )
 );
 
-export default withUsersConsumer(withTracker(({ users }) => {
+export default withTracker(() => {
   const currentPresentations = Service.getPresentations();
   const {
     dispatchDisableDownloadable,
@@ -27,8 +26,6 @@ export default withUsersConsumer(withTracker(({ users }) => {
     dispatchTogglePresentationDownloadable,
   } = Service;
 
-  const currentUser = users[Auth.meetingID][Auth.userID];
-
   return {
     presentations: currentPresentations,
     defaultFileName: PRESENTATION_CONFIG.defaultPresentationFile,
@@ -44,6 +41,6 @@ export default withUsersConsumer(withTracker(({ users }) => {
     dispatchTogglePresentationDownloadable,
     isOpen: Session.get('showUploadPresentationView') || false,
     selectedToBeNextCurrent: Session.get('selectedToBeNextCurrent') || null,
-    isPresenter: currentUser.presenter,
+    isPresenter: PresentationService.isPresenter('DEFAULT_PRESENTATION_POD'),
   };
-})(PresentationUploaderContainer));
+})(PresentationUploaderContainer);
diff --git a/bigbluebutton-html5/imports/ui/components/presentation/service.js b/bigbluebutton-html5/imports/ui/components/presentation/service.js
index bf3ee75866..5c82cda4af 100755
--- a/bigbluebutton-html5/imports/ui/components/presentation/service.js
+++ b/bigbluebutton-html5/imports/ui/components/presentation/service.js
@@ -155,17 +155,12 @@ const parseCurrentSlideContent = (yesValue, noValue, abstentionValue, trueValue,
 };
 
 const isPresenter = (podId) => {
-  // a main presenter in the meeting always owns a default pod
-  if (podId !== 'DEFAULT_PRESENTATION_POD') {
-    // if a pod is not default, then we check whether this user owns a current pod
-    const selector = {
-      meetingId: Auth.meetingID,
-      podId,
-    };
-    const pod = PresentationPods.findOne(selector);
-    return pod.currentPresenterId === Auth.userID;
-  }
-  return true;
+  const selector = {
+    meetingId: Auth.meetingID,
+    podId,
+  };
+  const pod = PresentationPods.findOne(selector);
+  return pod?.currentPresenterId === Auth.userID;
 };
 
 export default {
-- 
GitLab