瀏覽代碼

fix stat unsub, one loop for updating

master
Leonard Kim 8 年之前
父節點
當前提交
2132cd6736

+ 1
- 1
react/features/connection-indicator/components/ConnectionIndicator.js 查看文件

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

+ 17
- 11
react/features/connection-indicator/statsEmitter.js 查看文件

@@ -1,3 +1,5 @@
1
+import _ from 'lodash';
2
+
1 3
 import JitsiMeetJS from '../base/lib-jitsi-meet';
2 4
 
3 5
 declare var APP: Object;
@@ -27,7 +29,7 @@ const statsEmitter = {
27 29
         const { connectionQuality } = JitsiMeetJS.events;
28 30
 
29 31
         conference.on(connectionQuality.LOCAL_STATS_UPDATED,
30
-            stats => this._onStatsUpdated(stats));
32
+            stats => this._onStatsUpdated(conference.myUserId(), stats));
31 33
 
32 34
         conference.on(connectionQuality.REMOTE_STATS_UPDATED,
33 35
             (id, stats) => this._emitStatsUpdate(id, stats));
@@ -100,15 +102,15 @@ const statsEmitter = {
100 102
      * also update listeners of remote user stats of changes related to their
101 103
      * stats.
102 104
      *
105
+     * @param {string} currentUserId - The user id for the local user.
103 106
      * @param {Object} stats - Connection stats for the local user as provided
104 107
      * by the library.
105 108
      * @returns {void}
106 109
      */
107
-    _onStatsUpdated(stats) {
110
+    _onStatsUpdated(currentUserId, stats) {
108 111
         const allUserFramerates = stats.framerate;
109 112
         const allUserResolutions = stats.resolution;
110 113
 
111
-        const currentUserId = APP.conference.getMyUserId();
112 114
         const currentUserFramerate = allUserFramerates[currentUserId];
113 115
         const currentUserResolution = allUserResolutions[currentUserId];
114 116
 
@@ -121,26 +123,30 @@ const statsEmitter = {
121 123
 
122 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 132
             .filter(id => id !== currentUserId)
126 133
             .forEach(id => {
134
+                const remoteUserStats = {};
135
+
127 136
                 const framerate = allUserFramerates[id];
128 137
 
129 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 142
                 const resolution = allUserResolutions[id];
138 143
 
139 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…
取消
儲存