From 848fdc3ed08254cc99539621ff0286c95596d506 Mon Sep 17 00:00:00 2001
From: Maxim Khlobystov <maxim.khlobystov@gmail.com>
Date: Wed, 28 Apr 2021 15:44:08 +0000
Subject: [PATCH] Make the random user picking countdown optional

---
 .../modal/random-user/component.jsx           | 43 +++++++++++--------
 .../private/config/settings.yml               |  1 +
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/bigbluebutton-html5/imports/ui/components/modal/random-user/component.jsx b/bigbluebutton-html5/imports/ui/components/modal/random-user/component.jsx
index 0e567bac41..497b414a1f 100644
--- a/bigbluebutton-html5/imports/ui/components/modal/random-user/component.jsx
+++ b/bigbluebutton-html5/imports/ui/components/modal/random-user/component.jsx
@@ -6,6 +6,8 @@ import Button from '/imports/ui/components/button/component';
 import AudioService from '/imports/ui/components/audio/service';
 import { styles } from './styles';
 
+const SELECT_RANDOM_USER_COUNTDOWN = Meteor.settings.public.selectRandomUser.countdown;
+
 const messages = defineMessages({
   noViewers: {
     id: 'app.modal.randomUser.noViewers.description',
@@ -54,11 +56,12 @@ class RandomUserSelect extends Component {
       props.randomUserReq();
     }
 
-    this.state = {
-      count: 0,
-    };
-
-    this.play = this.play.bind(this);
+    if(SELECT_RANDOM_USER_COUNTDOWN) {
+      this.state = {
+        count: 0,
+      };
+      this.play = this.play.bind(this);
+    }
   }
 
   iterateSelection() {
@@ -77,18 +80,20 @@ class RandomUserSelect extends Component {
   }
 
   componentDidMount() {
-    if (!this.props.currentUser.presenter) {
+    if (SELECT_RANDOM_USER_COUNTDOWN && !this.props.currentUser.presenter) {
       this.iterateSelection();
     }
   }
 
   componentDidUpdate(prevProps, prevState) {
-    if (this.props.currentUser.presenter && this.state.count == 0) {
-      this.iterateSelection();
-    }
+    if(SELECT_RANDOM_USER_COUNTDOWN) {
+      if (this.props.currentUser.presenter && this.state.count == 0) {
+        this.iterateSelection();
+      }
 
-    if (prevState.count !== this.state.count) {
-      this.play();
+      if (prevState.count !== this.state.count) {
+        this.play();
+      }
     }
   }
 
@@ -100,9 +105,11 @@ class RandomUserSelect extends Component {
   }
 
   reselect() {
-    this.setState({
-      count: 0,
-    });
+    if(SELECT_RANDOM_USER_COUNTDOWN) {
+      this.setState({
+        count: 0,
+      });
+    }
     this.props.randomUserReq();
   }
 
@@ -116,10 +123,12 @@ class RandomUserSelect extends Component {
       mappedRandomlySelectedUsers,
     } = this.props;
 
-    if (mappedRandomlySelectedUsers.length < this.state.count + 1) return null;
+    const counter = SELECT_RANDOM_USER_COUNTDOWN ? this.state.count : 0;
+    if (mappedRandomlySelectedUsers.length < counter + 1) return null;
 
-    const selectedUser = mappedRandomlySelectedUsers[this.state.count][0];
-    const countDown = mappedRandomlySelectedUsers.length - this.state.count - 1;
+    const selectedUser = mappedRandomlySelectedUsers[counter][0];
+    const countDown = SELECT_RANDOM_USER_COUNTDOWN ?
+      mappedRandomlySelectedUsers.length - this.state.count - 1 : 0;
 
     let viewElement;
 
diff --git a/bigbluebutton-html5/private/config/settings.yml b/bigbluebutton-html5/private/config/settings.yml
index 569122047f..8a91e1d152 100755
--- a/bigbluebutton-html5/private/config/settings.yml
+++ b/bigbluebutton-html5/private/config/settings.yml
@@ -504,6 +504,7 @@ public:
         mime: image/png
   selectRandomUser:
     enabled: true
+    countdown: false
   user:
     role_moderator: MODERATOR
     role_viewer: VIEWER
-- 
GitLab