Procházet zdrojové kódy

fix(Prejoin): Join click before conference.init()

master
Hristo Terezov před 4 roky
rodič
revize
0214138863
1 změnil soubory, kde provedl 23 přidání a 2 odebrání
  1. 23
    2
      conference.js

+ 23
- 2
conference.js Zobrazit soubor

@@ -156,6 +156,15 @@ let connection;
156 156
  */
157 157
 let _connectionPromise;
158 158
 
159
+/**
160
+ * We are storing the resolve function of a Promise that waits for the _connectionPromise to be created. This is needed
161
+ * when the prejoin button was pressed before the conference object was initialized and the _connectionPromise has not
162
+ * been initialized when we tried to execute prejoinStart. In this case in prejoinStart we create a new Promise, assign
163
+ * the resolve function to this variable and wait for the promise to resolve before we continue. The
164
+ * _onConnectionPromiseCreated will be called once the _connectionPromise is created.
165
+ */
166
+let _onConnectionPromiseCreated;
167
+
159 168
 /**
160 169
  * This promise is used for chaining mutePresenterVideo calls in order to avoid  calling GUM multiple times if it takes
161 170
  * a while to finish.
@@ -794,6 +803,10 @@ export default {
794 803
                 return c;
795 804
             });
796 805
 
806
+            if (_onConnectionPromiseCreated) {
807
+                _onConnectionPromiseCreated();
808
+            }
809
+
797 810
             APP.store.dispatch(makePrecallTest(this._getConferenceOptions()));
798 811
 
799 812
             const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions);
@@ -837,12 +850,20 @@ export default {
837 850
      * Joins conference after the tracks have been configured in the prejoin screen.
838 851
      *
839 852
      * @param {Object[]} tracks - An array with the configured tracks
840
-     * @returns {Promise}
853
+     * @returns {void}
841 854
      */
842 855
     async prejoinStart(tracks) {
856
+        if (!_connectionPromise) {
857
+            // The conference object isn't initialized yet. Wait for the promise to initialise.
858
+            await new Promise(resolve => {
859
+                _onConnectionPromiseCreated = resolve;
860
+            });
861
+            _onConnectionPromiseCreated = undefined;
862
+        }
863
+
843 864
         const con = await _connectionPromise;
844 865
 
845
-        return this.startConference(con, tracks);
866
+        this.startConference(con, tracks);
846 867
     },
847 868
 
848 869
     /**

Načítá se…
Zrušit
Uložit