Commit a1d7076e authored by JC Brand's avatar JC Brand

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

So that the BOSH connection will be restored before we trigger `connectionInitialized`
parent fd4ba891
...@@ -526,7 +526,7 @@ function clearSession () { ...@@ -526,7 +526,7 @@ function clearSession () {
* Creates a new Strophe.Connection instance and if applicable, attempt to * 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. * 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.connection) {
if (!_converse.bosh_service_url && ! _converse.websocket_url) { 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."); 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 () { ...@@ -550,7 +550,7 @@ _converse.initConnection = function () {
"websockets and bosh_service_url wasn't specified."); "websockets and bosh_service_url wasn't specified.");
} }
if (_converse.auto_login || _converse.keepalive) { if (_converse.auto_login || _converse.keepalive) {
_converse.api.user.login(); await _converse.api.user.login();
} }
} }
setUpXMLLogging(); setUpXMLLogging();
...@@ -653,7 +653,7 @@ function setUpXMLLogging () { ...@@ -653,7 +653,7 @@ function setUpXMLLogging () {
async function finishInitialization () { async function finishInitialization () {
initClientConfig(); initClientConfig();
initPlugins(); initPlugins();
_converse.initConnection(); await _converse.initConnection();
_converse.registerGlobalEventHandlers(); _converse.registerGlobalEventHandlers();
if (!Backbone.history.started) { if (!Backbone.history.started) {
Backbone.history.start(); Backbone.history.start();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment