Browse Source

fix(conference): initialize UI features on CONFERENCE_JOINED

Initializing UI features, like keyboard shortcuts, by chaining
onto APP.conference.init is not safe because init can fail,
skipping the initializing of UI features. This can happen when
the room is locked and then a failure event is dispatched into
middleware. I couldn't find a place to properly chain onto
in the APP.conference.init promise chain, primarily due
to the flow continued within middleware, so instead I
leveraged an existing listener for CONFERENCE_JOINED.
j8
Leonard Kim 7 years ago
parent
commit
bb45f76a7a
2 changed files with 58 additions and 49 deletions
  1. 57
    5
      conference.js
  2. 1
    44
      react/features/base/connection/actions.web.js

+ 57
- 5
conference.js View File

@@ -1702,11 +1702,7 @@ export default {
1702 1702
     _setupListeners() {
1703 1703
         // add local streams when joined to the conference
1704 1704
         room.on(JitsiConferenceEvents.CONFERENCE_JOINED, () => {
1705
-            APP.store.dispatch(conferenceJoined(room));
1706
-
1707
-            APP.UI.mucJoined();
1708
-            APP.API.notifyConferenceJoined(APP.conference.roomName);
1709
-            APP.UI.markVideoInterrupted(false);
1705
+            this._onConferenceJoined();
1710 1706
         });
1711 1707
 
1712 1708
         room.on(
@@ -2334,6 +2330,62 @@ export default {
2334 2330
             });
2335 2331
     },
2336 2332
 
2333
+    /**
2334
+     * Callback invoked when the conference has been successfully joined.
2335
+     * Initializes the UI and various other features.
2336
+     *
2337
+     * @private
2338
+     * @returns {void}
2339
+     */
2340
+    _onConferenceJoined() {
2341
+        if (APP.logCollector) {
2342
+            // Start the LogCollector's periodic "store logs" task
2343
+            APP.logCollector.start();
2344
+            APP.logCollectorStarted = true;
2345
+
2346
+            // Make an attempt to flush in case a lot of logs have been
2347
+            // cached, before the collector was started.
2348
+            APP.logCollector.flush();
2349
+
2350
+            // This event listener will flush the logs, before
2351
+            // the statistics module (CallStats) is stopped.
2352
+            //
2353
+            // NOTE The LogCollector is not stopped, because this event can
2354
+            // be triggered multiple times during single conference
2355
+            // (whenever statistics module is stopped). That includes
2356
+            // the case when Jicofo terminates the single person left in the
2357
+            // room. It will then restart the media session when someone
2358
+            // eventually join the room which will start the stats again.
2359
+            APP.conference.addConferenceListener(
2360
+                JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
2361
+                () => {
2362
+                    if (APP.logCollector) {
2363
+                        APP.logCollector.flush();
2364
+                    }
2365
+                }
2366
+            );
2367
+        }
2368
+
2369
+        APP.UI.initConference();
2370
+
2371
+        APP.UI.addListener(
2372
+            UIEvents.LANG_CHANGED,
2373
+            language => APP.translation.setLanguage(language));
2374
+
2375
+        APP.keyboardshortcut.init();
2376
+
2377
+        if (config.requireDisplayName
2378
+                && !APP.conference.getLocalDisplayName()) {
2379
+            APP.UI.promptDisplayName();
2380
+        }
2381
+
2382
+        APP.store.dispatch(conferenceJoined(room));
2383
+
2384
+        APP.UI.mucJoined();
2385
+        APP.API.notifyConferenceJoined(APP.conference.roomName);
2386
+        APP.UI.markVideoInterrupted(false);
2387
+    },
2388
+
2337 2389
     /**
2338 2390
     * Adds any room listener.
2339 2391
     * @param {string} eventName one of the JitsiConferenceEvents

+ 1
- 44
react/features/base/connection/actions.web.js View File

@@ -3,12 +3,10 @@
3 3
 import type { Dispatch } from 'redux';
4 4
 
5 5
 import {
6
-    JitsiConferenceEvents,
7 6
     libInitError,
8 7
     WEBRTC_NOT_READY,
9 8
     WEBRTC_NOT_SUPPORTED
10 9
 } from '../lib-jitsi-meet';
11
-import UIEvents from '../../../../service/UI/UIEvents';
12 10
 
13 11
 declare var APP: Object;
14 12
 declare var config: Object;
@@ -35,48 +33,7 @@ export function connect() {
35 33
 
36 34
         // XXX For web based version we use conference initialization logic
37 35
         // from the old app (at the moment of writing).
38
-        return APP.conference.init({ roomName: room }).then(() => {
39
-            if (APP.logCollector) {
40
-                // Start the LogCollector's periodic "store logs" task
41
-                APP.logCollector.start();
42
-                APP.logCollectorStarted = true;
43
-
44
-                // Make an attempt to flush in case a lot of logs have been
45
-                // cached, before the collector was started.
46
-                APP.logCollector.flush();
47
-
48
-                // This event listener will flush the logs, before
49
-                // the statistics module (CallStats) is stopped.
50
-                //
51
-                // NOTE The LogCollector is not stopped, because this event can
52
-                // be triggered multiple times during single conference
53
-                // (whenever statistics module is stopped). That includes
54
-                // the case when Jicofo terminates the single person left in the
55
-                // room. It will then restart the media session when someone
56
-                // eventually join the room which will start the stats again.
57
-                APP.conference.addConferenceListener(
58
-                    JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED,
59
-                    () => {
60
-                        if (APP.logCollector) {
61
-                            APP.logCollector.flush();
62
-                        }
63
-                    }
64
-                );
65
-            }
66
-
67
-            APP.UI.initConference();
68
-
69
-            APP.UI.addListener(
70
-                UIEvents.LANG_CHANGED,
71
-                language => APP.translation.setLanguage(language));
72
-
73
-            APP.keyboardshortcut.init();
74
-
75
-            if (config.requireDisplayName
76
-                    && !APP.conference.getLocalDisplayName()) {
77
-                APP.UI.promptDisplayName();
78
-            }
79
-        })
36
+        return APP.conference.init({ roomName: room })
80 37
             .catch(error => {
81 38
                 APP.API.notifyConferenceLeft(APP.conference.roomName);
82 39
                 logger.error(error);

Loading…
Cancel
Save