瀏覽代碼

ref(thumbnail): use connectionStatus from redux.

j8
Hristo Terezov 4 年之前
父節點
當前提交
f45af351d8

+ 0
- 14
conference.js 查看文件

@@ -1134,20 +1134,6 @@ export default {
1134 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 1138
      * Gets the display name foe the <tt>JitsiParticipant</tt> identified by
1153 1139
      * the given <tt>id</tt>.

+ 5
- 5
modules/UI/videolayout/LargeVideoManager.js 查看文件

@@ -12,6 +12,7 @@ import {
12 12
     JitsiParticipantConnectionStatus
13 13
 } from '../../../react/features/base/lib-jitsi-meet';
14 14
 import { VIDEO_TYPE } from '../../../react/features/base/media';
15
+import { getParticipantById } from '../../../react/features/base/participants';
15 16
 import { CHAT_SIZE } from '../../../react/features/chat';
16 17
 import {
17 18
     updateKnownLargeVideoResolution
@@ -224,9 +225,8 @@ export default class LargeVideoManager {
224 225
             const wasUsersImageCached
225 226
                 = !isUserSwitch && container.wasVideoRendered;
226 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 230
             const isVideoRenderable
231 231
                 = !isVideoMuted
232 232
                     && (APP.conference.isLocalId(id)
@@ -479,8 +479,8 @@ export default class LargeVideoManager {
479 479
      */
480 480
     showRemoteConnectionMessage(show) {
481 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 485
             // eslint-disable-next-line no-param-reassign
486 486
             show = !APP.conference.isLocalId(this.id)

+ 8
- 33
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -323,9 +323,11 @@ export default class RemoteVideo extends SmallVideo {
323 323
      * @private
324 324
      */
325 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 332
         if (!isActive && isVideoMuted) {
331 333
             this.mutedWhileDisconnected = true;
@@ -364,17 +366,6 @@ export default class RemoteVideo extends SmallVideo {
364 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 370
      * The remote video is considered "playable" once the can play event has been received. It will be allowed to
380 371
      * display video also in {@link JitsiParticipantConnectionStatus.INTERRUPTED} if the video has received the canplay
@@ -386,7 +377,8 @@ export default class RemoteVideo extends SmallVideo {
386 377
      * @override
387 378
      */
388 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 383
         return super.isVideoPlayable()
392 384
             && this._canPlayEventReceived
@@ -399,25 +391,8 @@ export default class RemoteVideo extends SmallVideo {
399 391
      */
400 392
     updateView() {
401 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 394
         this._figureOutMutedWhileDisconnected();
420
-        this.updateConnectionStatus(connectionStatus);
395
+        super.updateView();
421 396
     }
422 397
 
423 398
     /**

+ 3
- 22
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -95,16 +95,6 @@ export default class SmallVideo {
95 95
         this.videoIsHovered = false;
96 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 99
          * Whether or not the connection indicator should be displayed.
110 100
          *
@@ -210,16 +200,6 @@ export default class SmallVideo {
210 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 204
      * Create or updates the ReactElement for displaying status indicators about
225 205
      * audio mute, video mute, and moderator status.
@@ -453,6 +433,7 @@ export default class SmallVideo {
453 433
      */
454 434
     computeDisplayModeInput() {
455 435
         let isScreenSharing = false;
436
+        let connectionStatus;
456 437
         const state = APP.store.getState();
457 438
         const participant = getParticipantById(state, this.id);
458 439
 
@@ -461,6 +442,7 @@ export default class SmallVideo {
461 442
             const track = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, this.id);
462 443
 
463 444
             isScreenSharing = typeof track !== 'undefined' && track.videoType === 'desktop';
445
+            connectionStatus = participant.connectionStatus;
464 446
         }
465 447
 
466 448
         return {
@@ -470,7 +452,7 @@ export default class SmallVideo {
470 452
             tileViewActive: shouldDisplayTileView(state),
471 453
             isVideoPlayable: this.isVideoPlayable(),
472 454
             hasVideo: Boolean(this.selectVideoElement().length),
473
-            connectionStatus: APP.conference.getParticipantConnectionStatus(this.id),
455
+            connectionStatus,
474 456
             mutedWhileDisconnected: this.mutedWhileDisconnected,
475 457
             canPlayEventReceived: this._canPlayEventReceived,
476 458
             videoStream: Boolean(this.videoStream),
@@ -714,7 +696,6 @@ export default class SmallVideo {
714 696
                             { this._showConnectionIndicator
715 697
                                 ? <ConnectionIndicator
716 698
                                     alwaysVisible = { showConnectionIndicator }
717
-                                    connectionStatus = { this._connectionStatus }
718 699
                                     iconSize = { iconSize }
719 700
                                     isLocalVideo = { this.isLocal }
720 701
                                     enableStatsDisplay = { !interfaceConfig.filmStripOnly }

+ 1
- 0
react/features/base/conference/functions.js 查看文件

@@ -73,6 +73,7 @@ export function commonUserJoinedHandling(
73 73
     } else {
74 74
         dispatch(participantJoined({
75 75
             botType: user.getBotType(),
76
+            connectionStatus: user.getConnectionStatus(),
76 77
             conference,
77 78
             id,
78 79
             name: displayName,

+ 28
- 19
react/features/connection-indicator/components/web/ConnectionIndicator.js 查看文件

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

Loading…
取消
儲存