Only clear messages when clear_messages_on_reconnection is true

This commit is contained in:
JC Brand 2019-08-03 18:26:27 +02:00
parent c038794fb5
commit c7b6bb4773
2 changed files with 7 additions and 5 deletions

View File

@ -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(
null, ['rosterGroupsFetched'], {},
null, ['rosterGroupsFetched'], {'clear_messages_on_reconnection': true},
async function (done, _converse) {
const muc_jid = 'lounge@montague.lit';

View File

@ -301,9 +301,9 @@ converse.plugins.add('converse-chatboxes', {
initMessages () {
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.on('change:upload', (message) => {
if (message.get('upload') === _converse.SUCCESS) {
_converse.api.send(this.createMessageStanza(message));
@ -349,8 +349,10 @@ converse.plugins.add('converse-chatboxes', {
} catch (e) {
_converse.log(e, Strophe.LogLevel.ERROR);
} finally {
if (_converse.clear_messages_on_reconnection) {
this.clearMessages();
}
}
},
announceReconnection () {