Sfoglia il codice sorgente

Let initConnection wait for for `_converse.api.login`

So that the BOSH connection will be restored before we trigger `connectionInitialized`
JC Brand 6 anni fa
parent
commit
a1d7076e93
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      src/headless/converse-core.js

+ 3 - 3
src/headless/converse-core.js

@@ -526,7 +526,7 @@ function clearSession  () {
  * Creates a new Strophe.Connection instance and if applicable, attempt to
  * restore the BOSH session or if `auto_login` is true, attempt to log in.
  */
-_converse.initConnection = function () {
+_converse.initConnection = async function () {
     if (!_converse.connection) {
         if (!_converse.bosh_service_url && ! _converse.websocket_url) {
             throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
@@ -550,7 +550,7 @@ _converse.initConnection = function () {
                             "websockets and bosh_service_url wasn't specified.");
         }
         if (_converse.auto_login || _converse.keepalive) {
-            _converse.api.user.login();
+            await _converse.api.user.login();
         }
     }
     setUpXMLLogging();
@@ -653,7 +653,7 @@ function setUpXMLLogging () {
 async function finishInitialization () {
     initClientConfig();
     initPlugins();
-    _converse.initConnection();
+    await _converse.initConnection();
     _converse.registerGlobalEventHandlers();
     if (!Backbone.history.started) {
         Backbone.history.start();