瀏覽代碼

fix(lastN): handle first lastN message correctly

The first time a lastN was received it was ignored because the old lastN was
null, handle that case properly.

Furthermore, use default function parameters to avoid a conditional.
dev1
Saúl Ibarra Corretgé 8 年之前
父節點
當前提交
d5d2678130
共有 1 個文件被更改,包括 6 次插入10 次删除
  1. 6
    10
      modules/RTC/RTC.js

+ 6
- 10
modules/RTC/RTC.js 查看文件

@@ -180,22 +180,18 @@ export default class RTC extends Listenable {
180 180
      * @param {array} lastNEndpoints the new Last N endpoints.
181 181
      * @private
182 182
      */
183
-    _onLastNChanged(lastNEndpoints) {
184
-        const oldLastNEndpoints = this._lastNEndpoints;
183
+    _onLastNChanged(lastNEndpoints = []) {
184
+        const oldLastNEndpoints = this._lastNEndpoints || [];
185 185
         let leavingLastNEndpoints = [];
186 186
         let enteringLastNEndpoints = [];
187 187
 
188 188
         this._lastNEndpoints = lastNEndpoints;
189 189
 
190
-        if (oldLastNEndpoints) {
191
-            leavingLastNEndpoints = oldLastNEndpoints.filter(
192
-                id => !this.isInLastN(id));
190
+        leavingLastNEndpoints = oldLastNEndpoints.filter(
191
+            id => !this.isInLastN(id));
193 192
 
194
-            if (lastNEndpoints) {
195
-                enteringLastNEndpoints = lastNEndpoints.filter(
196
-                    id => oldLastNEndpoints.indexOf(id) === -1);
197
-            }
198
-        }
193
+        enteringLastNEndpoints = lastNEndpoints.filter(
194
+            id => oldLastNEndpoints.indexOf(id) === -1);
199 195
 
200 196
         this.conference.eventEmitter.emit(
201 197
             JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,

Loading…
取消
儲存