diff --git a/CHANGES.md b/CHANGES.md index 7c97301bb..26a0723b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ By setting this option to `false` and `view_mode` to `'embedded'`, it's now possible to "embed" the full app and not just a single chat. To embed just a single chat, it's now necessary to explicitly set `singleton` to `true`. +- Re-add the previously removed config option [keepalive](https://conversejs.org/docs/html/configuration.html#keepalive) - New event: [chatBoxBlurred](https://conversejs.org/docs/html/api/-_converse.html#event:chatBoxBlurred) - New event: [chatReconnected](https://conversejs.org/docs/html/api/-_converse.html#event:chatReconnected) - #316: Add support for XEP-0198 Stream Management diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index dd3a63793..bb5be9ae9 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -758,6 +758,15 @@ messaging instead. This value may be provided together with a ``password`` instead of supplying a `credentials_url`_ when setting ``auto_login`` to ``true``. +.. _`keepalive`: + +keepalive +--------- + +* Default: ``true`` + +Determines whether Converse will attempt to keep you logged in across page loads. + .. _`locales`: diff --git a/src/headless/converse-core.js b/src/headless/converse-core.js index a63f25318..f36ac24e3 100644 --- a/src/headless/converse-core.js +++ b/src/headless/converse-core.js @@ -218,6 +218,7 @@ _converse.default_settings = { geouri_replacement: 'https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2', idle_presence_timeout: 300, // Seconds after which an idle presence is sent jid: undefined, + keepalive: true, locales_url: 'locale/{{{locale}}}/LC_MESSAGES/converse.json', locales: [ 'af', 'ar', 'bg', 'ca', 'cs', 'de', 'eo', 'es', 'eu', 'en', 'fr', 'gl', @@ -525,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 = async function () { +_converse.initConnection = 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."); @@ -541,17 +542,15 @@ _converse.initConnection = async function () { Object.assign( _converse.default_connection_options, _converse.connection_options, - {'keepalive': true} + {'keepalive': _converse.keepalive} ) ); } else { throw new Error("initConnection: this browser does not support "+ "websockets and bosh_service_url wasn't specified."); } - if (_converse.auto_login) { + if (_converse.auto_login || _converse.keepalive) { _converse.api.user.login(); - } else if (_converse.api.connection.isType('bosh')) { - await _converse.restoreBOSHSession(); } } setUpXMLLogging(); @@ -654,7 +653,7 @@ function setUpXMLLogging () { async function finishInitialization () { initClientConfig(); initPlugins(); - await _converse.initConnection(); + _converse.initConnection(); _converse.registerGlobalEventHandlers(); if (!Backbone.history.started) { Backbone.history.start();