Commit bb0c0fcd authored by JC Brand's avatar JC Brand

Remove message views when messages get reset

parent b4b7fedf
......@@ -339,7 +339,10 @@ converse.plugins.add('converse-chatview', {
this.initDebounced();
this.model.messages.on('add', this.onMessageAdded, this);
this.model.messages.on('rendered', this.scrollDown, this);
this.model.messages.on('reset', () => (this.content.innerHTML = ''));
this.model.messages.on('reset', () => {
this.content.innerHTML = '';
this.removeAll();
});
this.model.on('show', this.show, this);
this.model.on('destroy', this.remove, this);
......
......@@ -152,7 +152,7 @@ converse.plugins.add('converse-mam-views', {
*/
const { _converse } = this;
/* Event handlers */
/************************ BEGIN Event Handlers ************************/
_converse.api.listen.on('afterMessagesFetched', chatbox => chatbox.fetchNewestMessages());
_converse.api.listen.on('reconnected', () => {
......@@ -161,5 +161,6 @@ converse.plugins.add('converse-mam-views', {
);
_.each(private_chats, view => view.model.fetchNewestMessages())
});
/************************ END Event Handlers ************************/
}
});
......@@ -541,7 +541,10 @@ converse.plugins.add('converse-muc-views', {
this.model.messages.on('add', this.onMessageAdded, this);
this.model.messages.on('rendered', this.scrollDown, this);
this.model.messages.on('reset', () => (this.content.innerHTML = ''));
this.model.messages.on('reset', () => {
this.content.innerHTML = '';
this.removeAll();
});
this.model.on('change:affiliation', this.renderHeading, this);
this.model.on('change:connection_status', this.onConnectionStatusChanged, this);
......
......@@ -301,7 +301,6 @@ converse.plugins.add('converse-chatboxes', {
this.messages.browserStorage = new Backbone.BrowserStorage.session(
`converse.messages-${this.get('jid')}-${_converse.bare_jid}`);
this.messages.chatbox = this;
this.messages.fetched = u.getResolveablePromise();
this.messages.on('change:upload', (message) => {
if (message.get('upload') === _converse.SUCCESS) {
......@@ -323,6 +322,7 @@ converse.plugins.add('converse-chatboxes', {
},
fetchMessages () {
this.messages.fetched = u.getResolveablePromise();
const resolve = this.messages.fetched.resolve;
this.messages.fetch({
'add': true,
......
......@@ -216,8 +216,8 @@ converse.plugins.add('converse-muc', {
this.initFeatures();
this.initOccupants();
this.initMessages();
this.registerHandlers();
this.initMessages();
},
async onConnectionStatusChanged () {
......@@ -1532,10 +1532,11 @@ converse.plugins.add('converse-muc', {
*/
_converse.chatboxes
.filter(m => (m.get('type') === _converse.CHATROOMS_TYPE))
.forEach(m => m.save('connection_status', converse.ROOMSTATUS.DISCONNECTED))
.forEach(room => {
room.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
room.clearMessages();
room.registerHandlers();
room.fetchMessages();
room.join();
});
}
......
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