Commit 4349b016 authored by JC Brand's avatar JC Brand

MUC: Only clear messages when MUC is left intentionally

by the user, and not as part of cleanup during logout or when leaving
automatically in order to receive XEP-0437 activity indicators.
parent c09511ad
......@@ -736,7 +736,6 @@ const ChatRoomMixin = {
async leave (exit_msg) {
this.features.destroy();
this.occupants.clearStore();
api.settings.get('muc_clear_messages_on_leave') && this.clearMessages();
const disco_entity = _converse.disco_entities?.get(this.get('jid'));
if (disco_entity) {
......@@ -748,7 +747,12 @@ const ChatRoomMixin = {
u.safeSave(this.session, { 'connection_status': converse.ROOMSTATUS.DISCONNECTED });
},
async close () {
async close (ev) {
await this.leave();
if (ev?.name !== 'closeAllChatBoxes' && api.settings.get('muc_clear_messages_on_leave')) {
this.clearMessages();
}
// Delete the session model
await new Promise(resolve =>
this.session.destroy({
......
......@@ -880,7 +880,7 @@ const ChatBoxView = View.extend({
this.model.setChatState(_converse.INACTIVE);
this.model.sendChatState();
}
await this.model.close();
await this.model.close(ev);
this.remove();
/**
* Triggered once a chatbox has been closed.
......
......@@ -730,12 +730,11 @@ const ChatRoomViewMixin = {
* @private
* @method _converse.ChatRoomView#close
*/
async close () {
close () {
this.hide();
if (_converse.router.history.getFragment() === 'converse/room?jid=' + this.model.get('jid')) {
_converse.router.navigate('');
}
await this.model.leave();
return _converse.ChatBoxView.prototype.close.apply(this, arguments);
},
......
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