Sfoglia il codice sorgente

Reduce direct read access to the features/base/participants redux state

As part of the work on fixing the problem with the multiplying
thumbnails, we've associated remote participant w/ JitsiConference.
However, there are periods of time when multiple JitsiConferences are in
the redux state (and that period is going to be shorted by
StateListenerRegistry). In order to give more control to the feature
base/participants, reduce the occurrences of direct access to the
features/base/participants redux state and utilize the feature's
existing read access functions. Which will allow us in the future to
enhance these functions to access participants which are relevant to the
current conference of interest to the user only.
j8
Lyubo Marinov 7 anni fa
parent
commit
8cd2bd272b

+ 1
- 4
react/features/base/participants/components/ParticipantView.native.js Vedi File

@@ -313,10 +313,7 @@ function _toBoolean(value, undefinedValue) {
313 313
  */
314 314
 function _mapStateToProps(state, ownProps) {
315 315
     const { participantId } = ownProps;
316
-    const participant
317
-        = getParticipantById(
318
-            state['features/base/participants'],
319
-            participantId);
316
+    const participant = getParticipantById(state, participantId);
320 317
     let avatar;
321 318
     let connectionStatus;
322 319
     let participantName;

+ 4
- 7
react/features/base/participants/functions.js Vedi File

@@ -240,11 +240,8 @@ export function isLocalParticipantModerator(stateful: Object | Function) {
240 240
         return false;
241 241
     }
242 242
 
243
-    const isModerator = localParticipant.role === PARTICIPANT_ROLE.MODERATOR;
244
-
245
-    if (state['features/base/config'].enableUserRolesBasedOnToken) {
246
-        return isModerator && !state['features/base/jwt'].isGuest;
247
-    }
248
-
249
-    return isModerator;
243
+    return (
244
+        localParticipant.role === PARTICIPANT_ROLE.MODERATOR
245
+            && (!state['features/base/config'].enableUserRolesBasedOnToken
246
+                || !state['features/base/jwt'].isGuest));
250 247
 }

+ 2
- 2
react/features/conference/components/Conference.native.js Vedi File

@@ -10,6 +10,7 @@ import { appNavigate } from '../../app';
10 10
 import { connect, disconnect } from '../../base/connection';
11 11
 import { DialogContainer } from '../../base/dialog';
12 12
 import { CalleeInfoContainer } from '../../base/jwt';
13
+import { getParticipantCount } from '../../base/participants';
13 14
 import { Container, LoadingIndicator, TintedView } from '../../base/react';
14 15
 import { TestConnectionInfo } from '../../base/testing';
15 16
 import { createDesiredLocalTracks } from '../../base/tracks';
@@ -383,7 +384,6 @@ function _mapStateToProps(state) {
383 384
     const { connecting, connection } = state['features/base/connection'];
384 385
     const { conference, joining, leaving } = state['features/base/conference'];
385 386
     const { reducedUI } = state['features/base/responsive-ui'];
386
-    const participants = state['features/base/participants'];
387 387
 
388 388
     // XXX There is a window of time between the successful establishment of the
389 389
     // XMPP connection and the subsequent commencement of joining the MUC during
@@ -415,7 +415,7 @@ function _mapStateToProps(state) {
415 415
          * @private
416 416
          * @type {number}
417 417
          */
418
-        _participantCount: participants.length,
418
+        _participantCount: getParticipantCount(state),
419 419
 
420 420
         /**
421 421
          * The indicator which determines whether the UI is reduced (to

+ 6
- 4
react/features/filmstrip/functions.js Vedi File

@@ -1,6 +1,9 @@
1 1
 // @flow
2 2
 
3
-import { getPinnedParticipant } from '../base/participants';
3
+import {
4
+    getParticipantCount,
5
+    getPinnedParticipant
6
+} from '../base/participants';
4 7
 
5 8
 declare var interfaceConfig: Object;
6 9
 
@@ -13,8 +16,7 @@ declare var interfaceConfig: Object;
13 16
  * in the filmstrip, then {@code true}; otherwise, {@code false}.
14 17
  */
15 18
 export function shouldRemoteVideosBeVisible(state: Object) {
16
-    const participants = state['features/base/participants'];
17
-    const participantCount = participants.length;
19
+    const participantCount = getParticipantCount(state);
18 20
     let pinnedParticipant;
19 21
 
20 22
     return Boolean(
@@ -26,7 +28,7 @@ export function shouldRemoteVideosBeVisible(state: Object) {
26 28
             || (participantCount > 1
27 29
                 && (state['features/filmstrip'].hovered
28 30
                     || state['features/toolbox'].visible
29
-                    || ((pinnedParticipant = getPinnedParticipant(participants))
31
+                    || ((pinnedParticipant = getPinnedParticipant(state))
30 32
                         && pinnedParticipant.local)))
31 33
 
32 34
             || (typeof interfaceConfig === 'object'

+ 4
- 4
react/features/invite/components/InfoDialogButton.web.js Vedi File

@@ -236,10 +236,10 @@ function _mapStateToProps(state) {
236 236
     return {
237 237
         _dialIn: state['features/invite'],
238 238
         _disableAutoShow: state['features/base/config'].iAmRecorder,
239
-        _liveStreamViewURL: currentLiveStreamingSession
240
-            && currentLiveStreamingSession.liveStreamViewURL,
241
-        _participantCount:
242
-            getParticipantCount(state['features/base/participants']),
239
+        _liveStreamViewURL:
240
+            currentLiveStreamingSession
241
+                && currentLiveStreamingSession.liveStreamViewURL,
242
+        _participantCount: getParticipantCount(state),
243 243
         _toolboxVisible: state['features/toolbox'].visible
244 244
     };
245 245
 }

+ 6
- 8
react/features/invite/middleware.any.js Vedi File

@@ -118,15 +118,13 @@ MiddlewareRegistry.register(store => next => action => {
118 118
  * @returns {string} - The presence status.
119 119
  */
120 120
 function _getParticipantPresence(state, id) {
121
-    if (!id) {
122
-        return undefined;
123
-    }
124
-    const participants = state['features/base/participants'];
125
-    const participantById = getParticipantById(participants, id);
121
+    if (id) {
122
+        const participantById = getParticipantById(state, id);
126 123
 
127
-    if (!participantById) {
128
-        return undefined;
124
+        if (participantById) {
125
+            return participantById.presence;
126
+        }
129 127
     }
130 128
 
131
-    return participantById.presence;
129
+    return undefined;
132 130
 }

+ 1
- 3
react/features/presence-status/components/PresenceLabel.js Vedi File

@@ -99,9 +99,7 @@ class PresenceLabel extends Component {
99 99
  * }}
100 100
  */
101 101
 function _mapStateToProps(state, ownProps) {
102
-    const participant
103
-        = getParticipantById(
104
-            state['features/base/participants'], ownProps.participantID);
102
+    const participant = getParticipantById(state, ownProps.participantID);
105 103
 
106 104
     return {
107 105
         _presence: participant && participant.presence

+ 1
- 4
react/features/remote-control/components/RemoteControlAuthorizationDialog.js Vedi File

@@ -159,10 +159,7 @@ class RemoteControlAuthorizationDialog extends Component<*> {
159 159
  */
160 160
 function _mapStateToProps(state, ownProps) {
161 161
     const { _displayName, participantId } = ownProps;
162
-    const participant
163
-        = getParticipantById(
164
-            state['features/base/participants'],
165
-            participantId);
162
+    const participant = getParticipantById(state, participantId);
166 163
 
167 164
     return {
168 165
         _displayName: participant ? participant.name : _displayName

+ 3
- 3
react/features/welcome/components/WelcomePageSideBar.native.js Vedi File

@@ -156,11 +156,11 @@ class WelcomePageSideBar extends Component<Props> {
156 156
  * @returns {Object}
157 157
  */
158 158
 function _mapStateToProps(state: Object) {
159
-    const _localParticipant = getLocalParticipant(state);
159
+    const localParticipant = getLocalParticipant(state);
160 160
 
161 161
     return {
162
-        _avatar: getAvatarURL(_localParticipant),
163
-        _displayName: getParticipantDisplayName(state, _localParticipant.id),
162
+        _avatar: getAvatarURL(localParticipant),
163
+        _displayName: getParticipantDisplayName(state, localParticipant.id),
164 164
         _visible: state['features/welcome'].sideBarVisible
165 165
     };
166 166
 }

Loading…
Annulla
Salva