Selaa lähdekoodia

Fixes #1471

Wait when fetching config, otherwise default of `true` for `trusted` is used erroneously.
JC Brand 4 vuotta sitten
vanhempi
commit
74ee783685
2 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 1 1
      src/converse-controlbox.js
  2. 3 3
      src/headless/converse-core.js

+ 1 - 1
src/converse-controlbox.js

@@ -420,7 +420,7 @@ converse.plugins.add('converse-controlbox', {
                 if (!this.validate()) { return; }
                 if (!this.validate()) { return; }
 
 
                 const form_data = new FormData(ev.target);
                 const form_data = new FormData(ev.target);
-                _converse.config.save({ 'trusted': form_data.get('trusted') && true || false });
+                _converse.config.save({'trusted': form_data.get('trusted') && true || false});
 
 
                 let jid = form_data.get('jid');
                 let jid = form_data.get('jid');
                 if (api.settings.get('locked_domain')) {
                 if (api.settings.get('locked_domain')) {

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

@@ -1069,7 +1069,7 @@ function initPlugins () {
 }
 }
 
 
 
 
-function initClientConfig () {
+async function initClientConfig () {
     /* The client config refers to configuration of the client which is
     /* The client config refers to configuration of the client which is
      * independent of any particular user.
      * independent of any particular user.
      * What this means is that config values need to persist across
      * What this means is that config values need to persist across
@@ -1078,7 +1078,7 @@ function initClientConfig () {
     const id = 'converse.client-config';
     const id = 'converse.client-config';
     _converse.config = new Model({ id, 'trusted': true });
     _converse.config = new Model({ id, 'trusted': true });
     _converse.config.browserStorage = createStore(id, "session");
     _converse.config.browserStorage = createStore(id, "session");
-    _converse.config.fetch();
+    await new Promise(r => _converse.config.fetch({'success': r, 'error': r}));
     /**
     /**
      * Triggered once the XMPP-client configuration has been initialized.
      * Triggered once the XMPP-client configuration has been initialized.
      * The client configuration is independent of any particular and its values
      * The client configuration is independent of any particular and its values
@@ -1559,7 +1559,7 @@ Object.assign(converse, {
         _converse.send_initial_presence = true;
         _converse.send_initial_presence = true;
 
 
         await initSessionStorage();
         await initSessionStorage();
-        initClientConfig();
+        await initClientConfig();
         await i18n.initialize();
         await i18n.initialize();
         initPlugins();
         initPlugins();
         registerGlobalEventHandlers();
         registerGlobalEventHandlers();