ソースを参照

Add /close command for chats

JC Brand 5 年 前
コミット
657dd1e6d1
3 ファイル変更8 行追加3 行削除
  1. 2 1
      spec/chatbox.js
  2. 5 2
      src/converse-chatview.js
  3. 1 0
      src/converse-muc-views.js

+ 2 - 1
spec/chatbox.js

@@ -27,9 +27,10 @@
                 test_utils.sendMessage(view, '/help');
 
                 const info_messages = Array.prototype.slice.call(view.el.querySelectorAll('.chat-info:not(.chat-date)'), 0);
-                expect(info_messages.length).toBe(3);
+                expect(info_messages.length).toBe(4);
                 expect(info_messages.pop().textContent).toBe('/help: Show this menu');
                 expect(info_messages.pop().textContent).toBe('/me: Write in the third person');
+                expect(info_messages.pop().textContent).toBe('/close: Close this chat');
                 expect(info_messages.pop().textContent).toBe('/clear: Remove messages');
 
                 const msg = $msg({

+ 5 - 2
src/converse-chatview.js

@@ -754,10 +754,13 @@ converse.plugins.add('converse-chatview', {
                     if (match[1] === "clear") {
                         this.clearMessages();
                         return true;
-                    }
-                    else if (match[1] === "help") {
+                    } else if (match[1] === "close") {
+                        this.close();
+                        return true;
+                    } else if (match[1] === "help") {
                         const msgs = [
                             `<strong>/clear</strong>: ${__('Remove messages')}`,
+                            `<strong>/close</strong>: ${__('Close this chat')}`,
                             `<strong>/me</strong>: ${__('Write in the third person')}`,
                             `<strong>/help</strong>: ${__('Show this menu')}`
                             ];

+ 1 - 0
src/converse-muc-views.js

@@ -1328,6 +1328,7 @@ converse.plugins.add('converse-muc-views', {
                             `<strong>/admin</strong>: ${__("Change user's affiliation to admin")}`,
                             `<strong>/ban</strong>: ${__('Ban user by changing their affiliation to outcast')}`,
                             `<strong>/clear</strong>: ${__('Clear the chat area')}`,
+                            `<strong>/close</strong>: ${__('Close this groupchat')}`,
                             `<strong>/deop</strong>: ${__('Change user role to participant')}`,
                             `<strong>/destroy</strong>: ${__('Remove this groupchat')}`,
                             `<strong>/help</strong>: ${__('Show this menu')}`,