Przeglądaj źródła

Don't set out message carbons IQ stanza on each page load.

JC Brand 10 lat temu
rodzic
commit
c646e93a9b
2 zmienionych plików z 7 dodań i 5 usunięć
  1. 6 5
      converse.js
  2. 1 0
      docs/CHANGES.rst

+ 6 - 5
converse.js

@@ -615,7 +615,7 @@
             /* Ask the XMPP server to enable Message Carbons
              * See XEP-0280 https://xmpp.org/extensions/xep-0280.html#enabling
              */
-            if (!this.message_carbons) {
+            if (!this.message_carbons || this.session.get('carbons_enabled')) {
                 return;
             }
             var carbons_iq = new Strophe.Builder('iq', {
@@ -624,14 +624,15 @@
                 type: 'set'
               })
               .c('enable', {xmlns: 'urn:xmpp:carbons:2'});
-            this.connection.send(carbons_iq);
-            this.connection.addHandler(function (iq) {
+            this.connection.addHandler($.proxy(function (iq) {
                 if ($(iq).find('error').length > 0) {
                     converse.log('ERROR: An error occured while trying to enable message carbons.');
                 } else {
-                    converse.log('Message carbons appear to have been enabled.');
+                    this.session.save({carbons_enabled: true});
+                    converse.log('Message carbons have been enabled.');
                 }
-            }, null, "iq", null, "enablecarbons");
+            }, this), null, "iq", null, "enablecarbons");
+            this.connection.send(carbons_iq);
         };
 
         this.onConnected = function () {

+ 1 - 0
docs/CHANGES.rst

@@ -7,6 +7,7 @@ Changelog
 * Norwegian Bokmål translations. [Andreas Lorentsen]
 * Updated Afrikaans translations. [jcbrand]
 * Add responsiveness to CSS. We now use Sass preprocessor for generating CSS. [jcbrand]
+* Don't send out the message carbons IQ stanza on each page load. [jcbrand]
 * #252, 253 Add fullname and jid to contact's tooltip in roster. [gbonvehi]
 * #292 Better support for XEP-0085 Chat State Notifications. [jcbrand]
 * #295 Document "allow_registration". [gbonvehi]