Browse Source

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 years ago
parent
commit
8cd2bd272b

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

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

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

240
         return false;
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 View File

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

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

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

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

236
     return {
236
     return {
237
         _dialIn: state['features/invite'],
237
         _dialIn: state['features/invite'],
238
         _disableAutoShow: state['features/base/config'].iAmRecorder,
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
         _toolboxVisible: state['features/toolbox'].visible
243
         _toolboxVisible: state['features/toolbox'].visible
244
     };
244
     };
245
 }
245
 }

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

118
  * @returns {string} - The presence status.
118
  * @returns {string} - The presence status.
119
  */
119
  */
120
 function _getParticipantPresence(state, id) {
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 View File

99
  * }}
99
  * }}
100
  */
100
  */
101
 function _mapStateToProps(state, ownProps) {
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
     return {
104
     return {
107
         _presence: participant && participant.presence
105
         _presence: participant && participant.presence

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

159
  */
159
  */
160
 function _mapStateToProps(state, ownProps) {
160
 function _mapStateToProps(state, ownProps) {
161
     const { _displayName, participantId } = ownProps;
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
     return {
164
     return {
168
         _displayName: participant ? participant.name : _displayName
165
         _displayName: participant ? participant.name : _displayName

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

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

Loading…
Cancel
Save