Browse Source

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

master
Hristo Terezov 4 years ago
parent
commit
0214138863
1 changed files with 23 additions and 2 deletions
  1. 23
    2
      conference.js

+ 23
- 2
conference.js View File

156
  */
156
  */
157
 let _connectionPromise;
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
  * This promise is used for chaining mutePresenterVideo calls in order to avoid  calling GUM multiple times if it takes
169
  * This promise is used for chaining mutePresenterVideo calls in order to avoid  calling GUM multiple times if it takes
161
  * a while to finish.
170
  * a while to finish.
794
                 return c;
803
                 return c;
795
             });
804
             });
796
 
805
 
806
+            if (_onConnectionPromiseCreated) {
807
+                _onConnectionPromiseCreated();
808
+            }
809
+
797
             APP.store.dispatch(makePrecallTest(this._getConferenceOptions()));
810
             APP.store.dispatch(makePrecallTest(this._getConferenceOptions()));
798
 
811
 
799
             const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions);
812
             const { tryCreateLocalTracks, errors } = this.createInitialLocalTracks(initialOptions);
837
      * Joins conference after the tracks have been configured in the prejoin screen.
850
      * Joins conference after the tracks have been configured in the prejoin screen.
838
      *
851
      *
839
      * @param {Object[]} tracks - An array with the configured tracks
852
      * @param {Object[]} tracks - An array with the configured tracks
840
-     * @returns {Promise}
853
+     * @returns {void}
841
      */
854
      */
842
     async prejoinStart(tracks) {
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
         const con = await _connectionPromise;
864
         const con = await _connectionPromise;
844
 
865
 
845
-        return this.startConference(con, tracks);
866
+        this.startConference(con, tracks);
846
     },
867
     },
847
 
868
 
848
     /**
869
     /**

Loading…
Cancel
Save