Browse Source

ref(thumbnail): use connectionStatus from redux.

master
Hristo Terezov 5 years ago
parent
commit
f45af351d8

+ 0
- 14
conference.js View File

1134
         return room ? room.getParticipantById(id) : null;
1134
         return room ? room.getParticipantById(id) : null;
1135
     },
1135
     },
1136
 
1136
 
1137
-    /**
1138
-     * Get participant connection status for the participant.
1139
-     *
1140
-     * @param {string} id participant's identifier(MUC nickname)
1141
-     *
1142
-     * @returns {ParticipantConnectionStatus|null} the status of the participant
1143
-     * or null if no such participant is found or participant is the local user.
1144
-     */
1145
-    getParticipantConnectionStatus(id) {
1146
-        const participant = this.getParticipantById(id);
1147
-
1148
-        return participant ? participant.getConnectionStatus() : null;
1149
-    },
1150
-
1151
     /**
1137
     /**
1152
      * Gets the display name foe the <tt>JitsiParticipant</tt> identified by
1138
      * Gets the display name foe the <tt>JitsiParticipant</tt> identified by
1153
      * the given <tt>id</tt>.
1139
      * the given <tt>id</tt>.

+ 5
- 5
modules/UI/videolayout/LargeVideoManager.js View File

12
     JitsiParticipantConnectionStatus
12
     JitsiParticipantConnectionStatus
13
 } from '../../../react/features/base/lib-jitsi-meet';
13
 } from '../../../react/features/base/lib-jitsi-meet';
14
 import { VIDEO_TYPE } from '../../../react/features/base/media';
14
 import { VIDEO_TYPE } from '../../../react/features/base/media';
15
+import { getParticipantById } from '../../../react/features/base/participants';
15
 import { CHAT_SIZE } from '../../../react/features/chat';
16
 import { CHAT_SIZE } from '../../../react/features/chat';
16
 import {
17
 import {
17
     updateKnownLargeVideoResolution
18
     updateKnownLargeVideoResolution
224
             const wasUsersImageCached
225
             const wasUsersImageCached
225
                 = !isUserSwitch && container.wasVideoRendered;
226
                 = !isUserSwitch && container.wasVideoRendered;
226
             const isVideoMuted = !stream || stream.isMuted();
227
             const isVideoMuted = !stream || stream.isMuted();
227
-
228
-            const connectionStatus
229
-                = APP.conference.getParticipantConnectionStatus(id);
228
+            const participant = getParticipantById(APP.store.getState(), id);
229
+            const connectionStatus = participant?.connectionStatus;
230
             const isVideoRenderable
230
             const isVideoRenderable
231
                 = !isVideoMuted
231
                 = !isVideoMuted
232
                     && (APP.conference.isLocalId(id)
232
                     && (APP.conference.isLocalId(id)
479
      */
479
      */
480
     showRemoteConnectionMessage(show) {
480
     showRemoteConnectionMessage(show) {
481
         if (typeof show !== 'boolean') {
481
         if (typeof show !== 'boolean') {
482
-            const connStatus
483
-                = APP.conference.getParticipantConnectionStatus(this.id);
482
+            const participant = getParticipantById(APP.store.getState(), this.id);
483
+            const connStatus = participant?.connectionStatus;
484
 
484
 
485
             // eslint-disable-next-line no-param-reassign
485
             // eslint-disable-next-line no-param-reassign
486
             show = !APP.conference.isLocalId(this.id)
486
             show = !APP.conference.isLocalId(this.id)

+ 8
- 33
modules/UI/videolayout/RemoteVideo.js View File

323
      * @private
323
      * @private
324
      */
324
      */
325
     _figureOutMutedWhileDisconnected() {
325
     _figureOutMutedWhileDisconnected() {
326
-        const isActive = this.isConnectionActive();
327
-        const isVideoMuted
328
-            = isRemoteTrackMuted(APP.store.getState()['features/base/tracks'], MEDIA_TYPE.VIDEO, this.id);
326
+        const state = APP.store.getState();
327
+        const participant = getParticipantById(state, this.id);
328
+        const connectionState = participant?.connectionStatus;
329
+        const isActive = connectionState === JitsiParticipantConnectionStatus.ACTIVE;
330
+        const isVideoMuted = isRemoteTrackMuted(state['features/base/tracks'], MEDIA_TYPE.VIDEO, this.id);
329
 
331
 
330
         if (!isActive && isVideoMuted) {
332
         if (!isActive && isVideoMuted) {
331
             this.mutedWhileDisconnected = true;
333
             this.mutedWhileDisconnected = true;
364
         this.updateView();
366
         this.updateView();
365
     }
367
     }
366
 
368
 
367
-    /**
368
-     * Checks whether the remote user associated with this <tt>RemoteVideo</tt>
369
-     * has connectivity issues.
370
-     *
371
-     * @return {boolean} <tt>true</tt> if the user's connection is fine or
372
-     * <tt>false</tt> otherwise.
373
-     */
374
-    isConnectionActive() {
375
-        return this.user.getConnectionStatus() === JitsiParticipantConnectionStatus.ACTIVE;
376
-    }
377
-
378
     /**
369
     /**
379
      * The remote video is considered "playable" once the can play event has been received. It will be allowed to
370
      * The remote video is considered "playable" once the can play event has been received. It will be allowed to
380
      * display video also in {@link JitsiParticipantConnectionStatus.INTERRUPTED} if the video has received the canplay
371
      * display video also in {@link JitsiParticipantConnectionStatus.INTERRUPTED} if the video has received the canplay
386
      * @override
377
      * @override
387
      */
378
      */
388
     isVideoPlayable() {
379
     isVideoPlayable() {
389
-        const connectionState = APP.conference.getParticipantConnectionStatus(this.id);
380
+        const participant = getParticipantById(APP.store.getState(), this.id);
381
+        const connectionState = participant?.connectionStatus;
390
 
382
 
391
         return super.isVideoPlayable()
383
         return super.isVideoPlayable()
392
             && this._canPlayEventReceived
384
             && this._canPlayEventReceived
399
      */
391
      */
400
     updateView() {
392
     updateView() {
401
         this.$container.toggleClass('audio-only', APP.conference.isAudioOnly());
393
         this.$container.toggleClass('audio-only', APP.conference.isAudioOnly());
402
-        this.updateConnectionStatusIndicator();
403
-
404
-        // This must be called after 'updateConnectionStatusIndicator' because it
405
-        // affects the display mode by modifying 'mutedWhileDisconnected' flag
406
-        super.updateView();
407
-    }
408
-
409
-    /**
410
-     * Updates the UI to reflect user's connectivity status.
411
-     */
412
-    updateConnectionStatusIndicator() {
413
-        const connectionStatus = this.user.getConnectionStatus();
414
-
415
-        logger.debug(`${this.id} thumbnail connection status: ${connectionStatus}`);
416
-
417
-        // FIXME rename 'mutedWhileDisconnected' to 'mutedWhileNotRendering'
418
-        // Update 'mutedWhileDisconnected' flag
419
         this._figureOutMutedWhileDisconnected();
394
         this._figureOutMutedWhileDisconnected();
420
-        this.updateConnectionStatus(connectionStatus);
395
+        super.updateView();
421
     }
396
     }
422
 
397
 
423
     /**
398
     /**

+ 3
- 22
modules/UI/videolayout/SmallVideo.js View File

95
         this.videoIsHovered = false;
95
         this.videoIsHovered = false;
96
         this.videoType = undefined;
96
         this.videoType = undefined;
97
 
97
 
98
-        /**
99
-         * The current state of the user's bridge connection. The value should be
100
-         * a string as enumerated in the library's participantConnectionStatus
101
-         * constants.
102
-         *
103
-         * @private
104
-         * @type {string|null}
105
-         */
106
-        this._connectionStatus = null;
107
-
108
         /**
98
         /**
109
          * Whether or not the connection indicator should be displayed.
99
          * Whether or not the connection indicator should be displayed.
110
          *
100
          *
210
         this.updateIndicators();
200
         this.updateIndicators();
211
     }
201
     }
212
 
202
 
213
-    /**
214
-     * Updates the connectionStatus stat which displays in the ConnectionIndicator.
215
-
216
-    * @returns {void}
217
-    */
218
-    updateConnectionStatus(connectionStatus) {
219
-        this._connectionStatus = connectionStatus;
220
-        this.updateIndicators();
221
-    }
222
-
223
     /**
203
     /**
224
      * Create or updates the ReactElement for displaying status indicators about
204
      * Create or updates the ReactElement for displaying status indicators about
225
      * audio mute, video mute, and moderator status.
205
      * audio mute, video mute, and moderator status.
453
      */
433
      */
454
     computeDisplayModeInput() {
434
     computeDisplayModeInput() {
455
         let isScreenSharing = false;
435
         let isScreenSharing = false;
436
+        let connectionStatus;
456
         const state = APP.store.getState();
437
         const state = APP.store.getState();
457
         const participant = getParticipantById(state, this.id);
438
         const participant = getParticipantById(state, this.id);
458
 
439
 
461
             const track = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, this.id);
442
             const track = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, this.id);
462
 
443
 
463
             isScreenSharing = typeof track !== 'undefined' && track.videoType === 'desktop';
444
             isScreenSharing = typeof track !== 'undefined' && track.videoType === 'desktop';
445
+            connectionStatus = participant.connectionStatus;
464
         }
446
         }
465
 
447
 
466
         return {
448
         return {
470
             tileViewActive: shouldDisplayTileView(state),
452
             tileViewActive: shouldDisplayTileView(state),
471
             isVideoPlayable: this.isVideoPlayable(),
453
             isVideoPlayable: this.isVideoPlayable(),
472
             hasVideo: Boolean(this.selectVideoElement().length),
454
             hasVideo: Boolean(this.selectVideoElement().length),
473
-            connectionStatus: APP.conference.getParticipantConnectionStatus(this.id),
455
+            connectionStatus,
474
             mutedWhileDisconnected: this.mutedWhileDisconnected,
456
             mutedWhileDisconnected: this.mutedWhileDisconnected,
475
             canPlayEventReceived: this._canPlayEventReceived,
457
             canPlayEventReceived: this._canPlayEventReceived,
476
             videoStream: Boolean(this.videoStream),
458
             videoStream: Boolean(this.videoStream),
714
                             { this._showConnectionIndicator
696
                             { this._showConnectionIndicator
715
                                 ? <ConnectionIndicator
697
                                 ? <ConnectionIndicator
716
                                     alwaysVisible = { showConnectionIndicator }
698
                                     alwaysVisible = { showConnectionIndicator }
717
-                                    connectionStatus = { this._connectionStatus }
718
                                     iconSize = { iconSize }
699
                                     iconSize = { iconSize }
719
                                     isLocalVideo = { this.isLocal }
700
                                     isLocalVideo = { this.isLocal }
720
                                     enableStatsDisplay = { !interfaceConfig.filmStripOnly }
701
                                     enableStatsDisplay = { !interfaceConfig.filmStripOnly }

+ 1
- 0
react/features/base/conference/functions.js View File

73
     } else {
73
     } else {
74
         dispatch(participantJoined({
74
         dispatch(participantJoined({
75
             botType: user.getBotType(),
75
             botType: user.getBotType(),
76
+            connectionStatus: user.getConnectionStatus(),
76
             conference,
77
             conference,
77
             id,
78
             id,
78
             name: displayName,
79
             name: displayName,

+ 28
- 19
react/features/connection-indicator/components/web/ConnectionIndicator.js View File

7
 import { Icon, IconConnectionActive, IconConnectionInactive } from '../../../base/icons';
7
 import { Icon, IconConnectionActive, IconConnectionInactive } from '../../../base/icons';
8
 import { JitsiParticipantConnectionStatus } from '../../../base/lib-jitsi-meet';
8
 import { JitsiParticipantConnectionStatus } from '../../../base/lib-jitsi-meet';
9
 import { MEDIA_TYPE } from '../../../base/media';
9
 import { MEDIA_TYPE } from '../../../base/media';
10
+import { getLocalParticipant, getParticipantById } from '../../../base/participants';
10
 import { Popover } from '../../../base/popover';
11
 import { Popover } from '../../../base/popover';
11
 import { connect } from '../../../base/redux';
12
 import { connect } from '../../../base/redux';
12
 import { getTrackByMediaTypeAndParticipant } from '../../../base/tracks';
13
 import { getTrackByMediaTypeAndParticipant } from '../../../base/tracks';
61
  */
62
  */
62
 type Props = AbstractProps & {
63
 type Props = AbstractProps & {
63
 
64
 
65
+    /**
66
+     * The current condition of the user's connection, matching one of the
67
+     * enumerated values in the library.
68
+     */
69
+    _connectionStatus: string,
70
+
64
     /**
71
     /**
65
      * Whether or not the component should ignore setting a visibility class for
72
      * Whether or not the component should ignore setting a visibility class for
66
      * hiding the component when the connection quality is not strong.
73
      * hiding the component when the connection quality is not strong.
72
      */
79
      */
73
     audioSsrc: number,
80
     audioSsrc: number,
74
 
81
 
75
-    /**
76
-     * The current condition of the user's connection, matching one of the
77
-     * enumerated values in the library.
78
-     */
79
-    connectionStatus: string,
80
-
81
     /**
82
     /**
82
      * The Redux dispatch function.
83
      * The Redux dispatch function.
83
      */
84
      */
200
      * @returns {string}
201
      * @returns {string}
201
      */
202
      */
202
     _getConnectionColorClass() {
203
     _getConnectionColorClass() {
203
-        const { connectionStatus } = this.props;
204
+        const { _connectionStatus } = this.props;
204
         const { percent } = this.state.stats;
205
         const { percent } = this.state.stats;
205
         const { INACTIVE, INTERRUPTED } = JitsiParticipantConnectionStatus;
206
         const { INACTIVE, INTERRUPTED } = JitsiParticipantConnectionStatus;
206
 
207
 
207
-        if (connectionStatus === INACTIVE) {
208
+        if (_connectionStatus === INACTIVE) {
208
             return 'status-other';
209
             return 'status-other';
209
-        } else if (connectionStatus === INTERRUPTED) {
210
+        } else if (_connectionStatus === INTERRUPTED) {
210
             return 'status-lost';
211
             return 'status-lost';
211
         } else if (typeof percent === 'undefined') {
212
         } else if (typeof percent === 'undefined') {
212
             return 'status-high';
213
             return 'status-high';
224
     _getConnectionStatusTip() {
225
     _getConnectionStatusTip() {
225
         let tipKey;
226
         let tipKey;
226
 
227
 
227
-        switch (this.props.connectionStatus) {
228
+        switch (this.props._connectionStatus) {
228
         case JitsiParticipantConnectionStatus.INTERRUPTED:
229
         case JitsiParticipantConnectionStatus.INTERRUPTED:
229
             tipKey = 'connectionindicator.quality.lost';
230
             tipKey = 'connectionindicator.quality.lost';
230
             break;
231
             break;
275
      * @returns {string}
276
      * @returns {string}
276
      */
277
      */
277
     _getVisibilityClass() {
278
     _getVisibilityClass() {
278
-        const { connectionStatus } = this.props;
279
+        const { _connectionStatus } = this.props;
279
 
280
 
280
         return this.state.showIndicator
281
         return this.state.showIndicator
281
             || this.props.alwaysVisible
282
             || this.props.alwaysVisible
282
-            || connectionStatus === JitsiParticipantConnectionStatus.INTERRUPTED
283
-            || connectionStatus === JitsiParticipantConnectionStatus.INACTIVE
283
+            || _connectionStatus === JitsiParticipantConnectionStatus.INTERRUPTED
284
+            || _connectionStatus === JitsiParticipantConnectionStatus.INACTIVE
284
             ? 'show-connection-indicator' : 'hide-connection-indicator';
285
             ? 'show-connection-indicator' : 'hide-connection-indicator';
285
     }
286
     }
286
 
287
 
304
      * @returns {ReactElement}
305
      * @returns {ReactElement}
305
      */
306
      */
306
     _renderIcon() {
307
     _renderIcon() {
307
-        if (this.props.connectionStatus
308
+        if (this.props._connectionStatus
308
             === JitsiParticipantConnectionStatus.INACTIVE) {
309
             === JitsiParticipantConnectionStatus.INACTIVE) {
309
             return (
310
             return (
310
                 <span className = 'connection_ninja'>
311
                 <span className = 'connection_ninja'>
319
         let iconWidth;
320
         let iconWidth;
320
         let emptyIconWrapperClassName = 'connection_empty';
321
         let emptyIconWrapperClassName = 'connection_empty';
321
 
322
 
322
-        if (this.props.connectionStatus
323
+        if (this.props._connectionStatus
323
             === JitsiParticipantConnectionStatus.INTERRUPTED) {
324
             === JitsiParticipantConnectionStatus.INTERRUPTED) {
324
 
325
 
325
             // emptyIconWrapperClassName is used by the torture tests to
326
             // emptyIconWrapperClassName is used by the torture tests to
434
  * @returns {Props}
435
  * @returns {Props}
435
  */
436
  */
436
 export function _mapStateToProps(state: Object, ownProps: Props) {
437
 export function _mapStateToProps(state: Object, ownProps: Props) {
437
-
438
+    const { participantId } = ownProps;
438
     const conference = state['features/base/conference'].conference;
439
     const conference = state['features/base/conference'].conference;
440
+    const participant
441
+        = typeof participantId === 'undefined' ? getLocalParticipant(state) : getParticipantById(state, participantId);
442
+    const props = {
443
+        _connectionStatus: participant?.connectionStatus
444
+    };
439
 
445
 
440
     if (conference) {
446
     if (conference) {
441
         const firstVideoTrack = getTrackByMediaTypeAndParticipant(
447
         const firstVideoTrack = getTrackByMediaTypeAndParticipant(
442
-            state['features/base/tracks'], MEDIA_TYPE.VIDEO, ownProps.participantId);
448
+            state['features/base/tracks'], MEDIA_TYPE.VIDEO, participantId);
443
         const firstAudioTrack = getTrackByMediaTypeAndParticipant(
449
         const firstAudioTrack = getTrackByMediaTypeAndParticipant(
444
-            state['features/base/tracks'], MEDIA_TYPE.AUDIO, ownProps.participantId);
450
+            state['features/base/tracks'], MEDIA_TYPE.AUDIO, participantId);
445
 
451
 
446
         return {
452
         return {
453
+            ...props,
447
             audioSsrc: firstAudioTrack ? conference.getSsrcByTrack(firstAudioTrack.jitsiTrack) : undefined,
454
             audioSsrc: firstAudioTrack ? conference.getSsrcByTrack(firstAudioTrack.jitsiTrack) : undefined,
448
             videoSsrc: firstVideoTrack ? conference.getSsrcByTrack(firstVideoTrack.jitsiTrack) : undefined
455
             videoSsrc: firstVideoTrack ? conference.getSsrcByTrack(firstVideoTrack.jitsiTrack) : undefined
449
         };
456
         };
450
     }
457
     }
451
 
458
 
452
-    return {};
459
+    return {
460
+        ...props
461
+    };
453
 }
462
 }
454
 export default translate(connect(_mapStateToProps, _mapDispatchToProps)(ConnectionIndicator));
463
 export default translate(connect(_mapStateToProps, _mapDispatchToProps)(ConnectionIndicator));

Loading…
Cancel
Save