Commit c7b6bb47 authored by JC Brand's avatar JC Brand

Only clear messages when `clear_messages_on_reconnection` is `true`

parent c038794f
...@@ -420,9 +420,9 @@ ...@@ -420,9 +420,9 @@
})); }));
}); });
it("clears cached messages when it gets closed", it("clears cached messages when it gets closed and clear_messages_on_reconnection is true",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {'clear_messages_on_reconnection': true},
async function (done, _converse) { async function (done, _converse) {
const muc_jid = 'lounge@montague.lit'; const muc_jid = 'lounge@montague.lit';
......
...@@ -301,9 +301,9 @@ converse.plugins.add('converse-chatboxes', { ...@@ -301,9 +301,9 @@ converse.plugins.add('converse-chatboxes', {
initMessages () { initMessages () {
this.messages = new this.messagesCollection(); this.messages = new this.messagesCollection();
this.messages.browserStorage = new BrowserStorage.session(this.getMessagesCacheKey()); const storage = _converse.config.get('storage');
this.messages.browserStorage = new BrowserStorage[storage](this.getMessagesCacheKey());
this.messages.chatbox = this; this.messages.chatbox = this;
this.messages.on('change:upload', (message) => { this.messages.on('change:upload', (message) => {
if (message.get('upload') === _converse.SUCCESS) { if (message.get('upload') === _converse.SUCCESS) {
_converse.api.send(this.createMessageStanza(message)); _converse.api.send(this.createMessageStanza(message));
...@@ -349,8 +349,10 @@ converse.plugins.add('converse-chatboxes', { ...@@ -349,8 +349,10 @@ converse.plugins.add('converse-chatboxes', {
} catch (e) { } catch (e) {
_converse.log(e, Strophe.LogLevel.ERROR); _converse.log(e, Strophe.LogLevel.ERROR);
} finally { } finally {
if (_converse.clear_messages_on_reconnection) {
this.clearMessages(); this.clearMessages();
} }
}
}, },
announceReconnection () { announceReconnection () {
......
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