瀏覽代碼

Fixes #1791: Adhere to the auto_focus setting

JC Brand 5 年之前
父節點
當前提交
2dae07fa87
共有 4 個文件被更改,包括 9 次插入10 次删除
  1. 1 0
      CHANGES.md
  2. 6 6
      src/converse-chatview.js
  3. 1 3
      src/converse-muc-views.js
  4. 1 1
      src/converse-roomslist.js

+ 1 - 0
CHANGES.md

@@ -30,6 +30,7 @@
 - #1691: Fix `collection.chatbox is undefined` errors
 - #1767: `credentials_url` is not called when logging out and then in again
 - #1772: `_converse.api.contact.add(jid, nick)` fails, says not a function
+- #1791: `auto_focus` set to `false` is ignored when switching back to a MUC
 - #1792: Fix: modals don't have scrollbars
 - #1796: Don't show "back" arrow navigation (on mobile) in the chat header when in `singleton` mode
 - #1821: Errors caused by malformed URLs are now handled

+ 6 - 6
src/converse-chatview.js

@@ -1214,6 +1214,10 @@ converse.plugins.add('converse-chatview', {
                 return this;
             },
 
+            maybeFocus () {
+                _converse.auto_focus && this.focus();
+            },
+
             hide () {
                 this.el.classList.add('hidden');
                 return this;
@@ -1223,16 +1227,12 @@ converse.plugins.add('converse-chatview', {
                 this.model.clearUnreadMsgCounter();
                 this.model.setChatState(_converse.ACTIVE);
                 this.scrollDown();
-                if (_converse.auto_focus) {
-                    this.focus();
-                }
+                this.maybeFocus();
             },
 
             show () {
                 if (u.isVisible(this.el)) {
-                    if (_converse.auto_focus) {
-                        this.focus();
-                    }
+                    this.maybeFocus();
                     return;
                 }
                 /**

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

@@ -1131,9 +1131,7 @@ converse.plugins.add('converse-muc-views', {
                 } else if (conn_status === converse.ROOMSTATUS.ENTERED) {
                     this.renderBottomPanel();
                     this.hideSpinner();
-                    if (_converse.auto_focus) {
-                        this.focus();
-                    }
+                    this.maybeFocus();
                 } else if (conn_status === converse.ROOMSTATUS.DISCONNECTED) {
                     this.showDisconnectMessage();
                 } else if (conn_status === converse.ROOMSTATUS.DESTROYED) {

+ 1 - 1
src/converse-roomslist.js

@@ -134,7 +134,7 @@ converse.plugins.add('converse-roomslist', {
                     'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)) || jid
                 }
                 await _converse.api.rooms.open(jid, data, true);
-                _converse.api.chatviews.get(jid).focus();
+                _converse.api.chatviews.get(jid).maybeFocus();
             },
 
             closeRoom (ev) {