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

This commit is contained in:
JC Brand 2015-01-17 13:24:05 +01:00
parent ad0f8a336a
commit c646e93a9b
2 changed files with 7 additions and 5 deletions

View File

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

View File

@ -7,6 +7,7 @@ Changelog
* Norwegian Bokmål translations. [Andreas Lorentsen] * Norwegian Bokmål translations. [Andreas Lorentsen]
* Updated Afrikaans translations. [jcbrand] * Updated Afrikaans translations. [jcbrand]
* Add responsiveness to CSS. We now use Sass preprocessor for generating CSS. [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] * #252, 253 Add fullname and jid to contact's tooltip in roster. [gbonvehi]
* #292 Better support for XEP-0085 Chat State Notifications. [jcbrand] * #292 Better support for XEP-0085 Chat State Notifications. [jcbrand]
* #295 Document "allow_registration". [gbonvehi] * #295 Document "allow_registration". [gbonvehi]