فهرست منبع

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.
JC Brand 4 سال پیش
والد
کامیت
4349b016eb
3فایلهای تغییر یافته به همراه8 افزوده شده و 5 حذف شده
  1. 6 2
      src/headless/plugins/muc/muc.js
  2. 1 1
      src/plugins/chatview/view.js
  3. 1 2
      src/plugins/muc-views/muc.js

+ 6 - 2
src/headless/plugins/muc/muc.js

@@ -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({

+ 1 - 1
src/plugins/chatview/view.js

@@ -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.

+ 1 - 2
src/plugins/muc-views/muc.js

@@ -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);
     },