diff --git a/spec/muc.js b/spec/muc.js index ca6bfcf1b..e1508053b 100644 --- a/spec/muc.js +++ b/spec/muc.js @@ -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'; diff --git a/src/headless/converse-chatboxes.js b/src/headless/converse-chatboxes.js index e5844c3ac..fc110a632 100644 --- a/src/headless/converse-chatboxes.js +++ b/src/headless/converse-chatboxes.js @@ -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,7 +349,9 @@ converse.plugins.add('converse-chatboxes', { } catch (e) { _converse.log(e, Strophe.LogLevel.ERROR); } finally { - this.clearMessages(); + if (_converse.clear_messages_on_reconnection) { + this.clearMessages(); + } } },