Browse Source

Add new config setting `lazy_load_vcards`

JC Brand 4 months ago
parent
commit
13976bf07f

+ 1 - 0
CHANGES.md

@@ -73,6 +73,7 @@
 - New "getOccupantActionButtons" hook, so that plugins can add actions on MUC occupants.
 - MUC occupants badges: displays short labels, with full label as title.
 - New config option [stanza_timeout](https://conversejs.org/docs/html/configuration.html#show-background)
+- New config option [lazy_load_vcards](https://conversejs.org/docs/html/configuration.html#lazy-load-vcards)
 - Update the "Add MUC" modal to add validation and to allow specifying only the MUC name and not the whole address.
 
 ### Default config changes

+ 11 - 0
docs/source/configuration.rst

@@ -742,6 +742,17 @@ a chat state indication of ``active`` will be sent out.
 
 A value of ``0`` means that this feature is disabled.
 
+.. _`lazy_load_vcards`:
+
+lazy_load_vcards
+----------------
+
+* Default:  ``true``
+
+Determines whether vCards are fetched lazily, i.e. only when their data should
+be shown in the UI, or eagerly, which is immediately once the entity the vCard
+relates to is known.
+
 .. _`loglevel`:
 
 loglevel

+ 4 - 0
src/headless/plugins/vcard/plugin.js

@@ -26,6 +26,10 @@ converse.plugins.add('converse-vcard', {
     },
 
     initialize () {
+        api.settings.extend({
+            lazy_load_vcards: true,
+        });
+
         api.promises.add('VCardsInitialized');
 
         const exports = { VCard, VCards };

+ 1 - 1
src/headless/plugins/vcard/vcard.js

@@ -17,7 +17,7 @@ class VCard extends Model {
      * @param {import("./types").VCardModelOptions} [options]
      */
     initialize(_attrs, options) {
-        this.lazy_load = !!options?.lazy_load;
+        this.lazy_load = api.settings.get('lazy_load_vcards') && !!options?.lazy_load;
 
         if (this.lazy_load) {
             this.once("visibilityChanged", () => api.vcard.update(this));