Selaa lähdekoodia

fix stat unsub, one loop for updating

j8
Leonard Kim 8 vuotta sitten
vanhempi
commit
2132cd6736

+ 1
- 1
react/features/connection-indicator/components/ConnectionIndicator.js Näytä tiedosto

168
     componentDidUpdate(prevProps) {
168
     componentDidUpdate(prevProps) {
169
         if (prevProps.userID !== this.props.userID) {
169
         if (prevProps.userID !== this.props.userID) {
170
             statsEmitter.unsubscribeToClientStats(
170
             statsEmitter.unsubscribeToClientStats(
171
-                this.props.userID, this._onStatsUpdated);
171
+                prevProps.userID, this._onStatsUpdated);
172
             statsEmitter.subscribeToClientStats(
172
             statsEmitter.subscribeToClientStats(
173
                 this.props.userID, this._onStatsUpdated);
173
                 this.props.userID, this._onStatsUpdated);
174
         }
174
         }

+ 17
- 11
react/features/connection-indicator/statsEmitter.js Näytä tiedosto

1
+import _ from 'lodash';
2
+
1
 import JitsiMeetJS from '../base/lib-jitsi-meet';
3
 import JitsiMeetJS from '../base/lib-jitsi-meet';
2
 
4
 
3
 declare var APP: Object;
5
 declare var APP: Object;
27
         const { connectionQuality } = JitsiMeetJS.events;
29
         const { connectionQuality } = JitsiMeetJS.events;
28
 
30
 
29
         conference.on(connectionQuality.LOCAL_STATS_UPDATED,
31
         conference.on(connectionQuality.LOCAL_STATS_UPDATED,
30
-            stats => this._onStatsUpdated(stats));
32
+            stats => this._onStatsUpdated(conference.myUserId(), stats));
31
 
33
 
32
         conference.on(connectionQuality.REMOTE_STATS_UPDATED,
34
         conference.on(connectionQuality.REMOTE_STATS_UPDATED,
33
             (id, stats) => this._emitStatsUpdate(id, stats));
35
             (id, stats) => this._emitStatsUpdate(id, stats));
100
      * also update listeners of remote user stats of changes related to their
102
      * also update listeners of remote user stats of changes related to their
101
      * stats.
103
      * stats.
102
      *
104
      *
105
+     * @param {string} currentUserId - The user id for the local user.
103
      * @param {Object} stats - Connection stats for the local user as provided
106
      * @param {Object} stats - Connection stats for the local user as provided
104
      * by the library.
107
      * by the library.
105
      * @returns {void}
108
      * @returns {void}
106
      */
109
      */
107
-    _onStatsUpdated(stats) {
110
+    _onStatsUpdated(currentUserId, stats) {
108
         const allUserFramerates = stats.framerate;
111
         const allUserFramerates = stats.framerate;
109
         const allUserResolutions = stats.resolution;
112
         const allUserResolutions = stats.resolution;
110
 
113
 
111
-        const currentUserId = APP.conference.getMyUserId();
112
         const currentUserFramerate = allUserFramerates[currentUserId];
114
         const currentUserFramerate = allUserFramerates[currentUserId];
113
         const currentUserResolution = allUserResolutions[currentUserId];
115
         const currentUserResolution = allUserResolutions[currentUserId];
114
 
116
 
121
 
123
 
122
         this._emitStatsUpdate(currentUserId, stats);
124
         this._emitStatsUpdate(currentUserId, stats);
123
 
125
 
124
-        Object.keys(allUserFramerates)
126
+        // Get all the unique user ids from the framerate and resolution stats
127
+        // and update remote user stats as needed.
128
+        const framerateUserIds = Object.keys(allUserFramerates);
129
+        const resolutionUserIds = Object.keys(allUserResolutions);
130
+
131
+        _.union(framerateUserIds, resolutionUserIds)
125
             .filter(id => id !== currentUserId)
132
             .filter(id => id !== currentUserId)
126
             .forEach(id => {
133
             .forEach(id => {
134
+                const remoteUserStats = {};
135
+
127
                 const framerate = allUserFramerates[id];
136
                 const framerate = allUserFramerates[id];
128
 
137
 
129
                 if (framerate) {
138
                 if (framerate) {
130
-                    this._emitStatsUpdate(id, { framerate });
139
+                    remoteUserStats.framerate = framerate;
131
                 }
140
                 }
132
-            });
133
 
141
 
134
-        Object.keys(allUserResolutions)
135
-            .filter(id => id !== currentUserId)
136
-            .forEach(id => {
137
                 const resolution = allUserResolutions[id];
142
                 const resolution = allUserResolutions[id];
138
 
143
 
139
                 if (resolution) {
144
                 if (resolution) {
140
-                    this._emitStatsUpdate(id, { resolution });
145
+                    remoteUserStats.resolution = resolution;
141
                 }
146
                 }
142
-            });
143
 
147
 
148
+                this._emitStatsUpdate(id, remoteUserStats);
149
+            });
144
     }
150
     }
145
 };
151
 };
146
 
152
 

Loading…
Peruuta
Tallenna