Commit 5a2d361c authored by JC Brand's avatar JC Brand

Fixes #2293: Message carbons not re-enabled when reconnecting

parent 476bcfe7
...@@ -744,7 +744,6 @@ export const ChatRoomView = ChatBoxView.extend({ ...@@ -744,7 +744,6 @@ export const ChatRoomView = ChatBoxView.extend({
* @method _converse.ChatRoomView#hideOccupants * @method _converse.ChatRoomView#hideOccupants
*/ */
hideOccupants (ev) { hideOccupants (ev) {
debugger;
if (ev) { if (ev) {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
......
...@@ -13,7 +13,10 @@ import { _converse, api, converse } from "./converse-core"; ...@@ -13,7 +13,10 @@ import { _converse, api, converse } from "./converse-core";
/* 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
*/ */
function enableCarbons () { function enableCarbons (reconnecting) {
if (reconnecting) {
_converse.session?.set({'carbons_enabled': false})
}
if (!api.settings.get("message_carbons") || _converse.session?.get('carbons_enabled')) { if (!api.settings.get("message_carbons") || _converse.session?.get('carbons_enabled')) {
return; return;
} }
...@@ -28,9 +31,10 @@ function enableCarbons () { ...@@ -28,9 +31,10 @@ function enableCarbons () {
if (iq.querySelectorAll('error').length > 0) { if (iq.querySelectorAll('error').length > 0) {
log.warn('An error occurred while trying to enable message carbons.'); log.warn('An error occurred while trying to enable message carbons.');
} else { } else {
_converse.session.save({'carbons_enabled': true}); _converse.session.set({'carbons_enabled': true});
log.debug('Message carbons have been enabled.'); log.debug('Message carbons have been enabled.');
} }
_converse.session.save(); // Gather multiple sets into one save
}, null, "iq", null, "enablecarbons"); }, null, "iq", null, "enablecarbons");
_converse.connection.send(carbons_iq); _converse.connection.send(carbons_iq);
} }
...@@ -43,6 +47,6 @@ converse.plugins.add('converse-carbons', { ...@@ -43,6 +47,6 @@ converse.plugins.add('converse-carbons', {
message_carbons: true message_carbons: true
}); });
api.listen.on('afterResourceBinding', () => enableCarbons()); api.listen.on('afterResourceBinding', enableCarbons);
} }
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment