Przeglądaj źródła

ref(video-layout): consolidate connection status update handling (#3185)

- Instead of having 4 listeners for local connection status
  updates and 1 for remote, remove two of the redundant listeners.
- Instead of calling into 4 separate VideoLayout methods to update a
  participant's connection status, expose one handler.
j8
virtuacoplenny 7 lat temu
rodzic
commit
9a06d2bf52

+ 0
- 12
conference.js Wyświetl plik

@@ -1785,13 +1785,6 @@ export default {
1785 1785
             id => APP.store.dispatch(dominantSpeakerChanged(id, room)));
1786 1786
 
1787 1787
         if (!interfaceConfig.filmStripOnly) {
1788
-            room.on(JitsiConferenceEvents.CONNECTION_INTERRUPTED, () => {
1789
-                APP.UI.markVideoInterrupted(true);
1790
-            });
1791
-            room.on(JitsiConferenceEvents.CONNECTION_RESTORED, () => {
1792
-                APP.UI.markVideoInterrupted(false);
1793
-            });
1794
-
1795 1788
             if (isButtonEnabled('chat')) {
1796 1789
                 room.on(
1797 1790
                     JitsiConferenceEvents.MESSAGE_RECEIVED,
@@ -1841,15 +1834,11 @@ export default {
1841 1834
         room.on(JitsiConferenceEvents.CONNECTION_INTERRUPTED, () => {
1842 1835
             APP.store.dispatch(localParticipantConnectionStatusChanged(
1843 1836
                 JitsiParticipantConnectionStatus.INTERRUPTED));
1844
-
1845
-            APP.UI.showLocalConnectionInterrupted(true);
1846 1837
         });
1847 1838
 
1848 1839
         room.on(JitsiConferenceEvents.CONNECTION_RESTORED, () => {
1849 1840
             APP.store.dispatch(localParticipantConnectionStatusChanged(
1850 1841
                 JitsiParticipantConnectionStatus.ACTIVE));
1851
-
1852
-            APP.UI.showLocalConnectionInterrupted(false);
1853 1842
         });
1854 1843
 
1855 1844
         room.on(
@@ -2317,7 +2306,6 @@ export default {
2317 2306
                     APP.store.getState(), this._room.myUserId())
2318 2307
             }
2319 2308
         );
2320
-        APP.UI.markVideoInterrupted(false);
2321 2309
     },
2322 2310
 
2323 2311
     /**

+ 0
- 23
modules/UI/UI.js Wyświetl plik

@@ -199,17 +199,6 @@ UI.changeDisplayName = function(id, displayName) {
199 199
     }
200 200
 };
201 201
 
202
-/**
203
- * Shows/hides the indication about local connection being interrupted.
204
- *
205
- * @param {boolean} isInterrupted <tt>true</tt> if local connection is
206
- * currently in the interrupted state or <tt>false</tt> if the connection
207
- * is fine.
208
- */
209
-UI.showLocalConnectionInterrupted = function(isInterrupted) {
210
-    VideoLayout.showLocalConnectionInterrupted(isInterrupted);
211
-};
212
-
213 202
 /**
214 203
  * Sets the "raised hand" status for a participant.
215 204
  *
@@ -774,18 +763,6 @@ UI.hideStats = function() {
774 763
     VideoLayout.hideStats();
775 764
 };
776 765
 
777
-/**
778
- * Mark video as interrupted or not.
779
- * @param {boolean} interrupted if video is interrupted
780
- */
781
-UI.markVideoInterrupted = function(interrupted) {
782
-    if (interrupted) {
783
-        VideoLayout.onVideoInterrupted();
784
-    } else {
785
-        VideoLayout.onVideoRestored();
786
-    }
787
-};
788
-
789 766
 /**
790 767
  * Add chat message.
791 768
  * @param {string} from user id

+ 24
- 50
modules/UI/videolayout/VideoLayout.js Wyświetl plik

@@ -583,25 +583,6 @@ const VideoLayout = {
583 583
         localVideoThumbnail.showAudioIndicator(isMuted);
584 584
     },
585 585
 
586
-    /**
587
-     * Shows/hides the indication about local connection being interrupted.
588
-     *
589
-     * @param {boolean} isInterrupted <tt>true</tt> if local connection is
590
-     * currently in the interrupted state or <tt>false</tt> if the connection
591
-     * is fine.
592
-     */
593
-    showLocalConnectionInterrupted(isInterrupted) {
594
-        // Currently local video thumbnail displays only "active" or
595
-        // "interrupted" despite the fact that ConnectionIndicator supports more
596
-        // states.
597
-        const status
598
-            = isInterrupted
599
-                ? JitsiParticipantConnectionStatus.INTERRUPTED
600
-                : JitsiParticipantConnectionStatus.ACTIVE;
601
-
602
-        localVideoThumbnail.updateConnectionStatus(status);
603
-    },
604
-
605 586
     /**
606 587
      * Resizes thumbnails.
607 588
      */
@@ -715,22 +696,31 @@ const VideoLayout = {
715 696
     },
716 697
 
717 698
     /**
718
-     * Shows/hides warning about remote user's connectivity issues.
699
+     * Shows/hides warning about a user's connectivity issues.
719 700
      *
720
-     * @param {string} id the ID of the remote participant(MUC nickname)
701
+     * @param {string} id - The ID of the remote participant(MUC nickname).
702
+     * @param {status} status - The new connection status.
703
+     * @returns {void}
721 704
      */
722
-    // eslint-disable-next-line no-unused-vars
723
-    onParticipantConnectionStatusChanged(id) {
724
-        // Show/hide warning on the large video
725
-        if (this.isCurrentlyOnLarge(id)) {
726
-            if (largeVideo) {
727
-                // We have to trigger full large video update to transition from
728
-                // avatar to video on connectivity restored.
729
-                this.updateLargeVideo(id, true /* force update */);
705
+    onParticipantConnectionStatusChanged(id, status) {
706
+        if (APP.conference.isLocalId(id)) {
707
+            // Maintain old logic of passing in either interrupted or active
708
+            // to updateConnectionStatus.
709
+            localVideoThumbnail.updateConnectionStatus(status);
710
+
711
+            if (status === JitsiParticipantConnectionStatus.INTERRUPTED) {
712
+                largeVideo && largeVideo.onVideoInterrupted();
713
+            } else {
714
+                largeVideo && largeVideo.onVideoRestored();
730 715
             }
716
+
717
+            return;
731 718
         }
732 719
 
733
-        // Show/hide warning on the thumbnail
720
+        // We have to trigger full large video update to transition from
721
+        // avatar to video on connectivity restored.
722
+        this._updateLargeVideoIfDisplayed(id, true);
723
+
734 724
         const remoteVideo = remoteVideos[id];
735 725
 
736 726
         if (remoteVideo) {
@@ -905,24 +895,6 @@ const VideoLayout = {
905 895
         }
906 896
     },
907 897
 
908
-    /**
909
-     * Indicates that the video has been interrupted.
910
-     */
911
-    onVideoInterrupted() {
912
-        if (largeVideo) {
913
-            largeVideo.onVideoInterrupted();
914
-        }
915
-    },
916
-
917
-    /**
918
-     * Indicates that the video has been restored.
919
-     */
920
-    onVideoRestored() {
921
-        if (largeVideo) {
922
-            largeVideo.onVideoRestored();
923
-        }
924
-    },
925
-
926 898
     isLargeVideoVisible() {
927 899
         return this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE);
928 900
     },
@@ -1176,11 +1148,13 @@ const VideoLayout = {
1176 1148
      *
1177 1149
      * @param {string} participantId - The participant ID that should trigger an
1178 1150
      * update of large video if displayed.
1151
+     * @param {boolean} force - Whether or not the large video update should
1152
+     * happen no matter what.
1179 1153
      * @returns {void}
1180 1154
      */
1181
-    _updateLargeVideoIfDisplayed(participantId) {
1155
+    _updateLargeVideoIfDisplayed(participantId, force = false) {
1182 1156
         if (this.isCurrentlyOnLarge(participantId)) {
1183
-            this.updateLargeVideo(participantId);
1157
+            this.updateLargeVideo(participantId, force);
1184 1158
         }
1185 1159
     }
1186 1160
 };

+ 2
- 1
react/features/video-layout/middleware.web.js Wyświetl plik

@@ -53,7 +53,8 @@ MiddlewareRegistry.register(store => next => action => {
53 53
         // explicit in order to minimize changes to other code.
54 54
         if (typeof action.participant.connectionStatus !== 'undefined') {
55 55
             VideoLayout.onParticipantConnectionStatusChanged(
56
-                action.participant.id);
56
+                action.participant.id,
57
+                action.participant.connectionStatus);
57 58
         }
58 59
         break;
59 60
     }

Ładowanie…
Anuluj
Zapisz