소스 검색

Add new config setting `muc_search_service`

Lets you configure which JID to use when searching for MUCs for
auto-complete purposes.

Fixes #3305
JC Brand 1 년 전
부모
커밋
851edc3746

+ 1 - 0
CHANGES.md

@@ -7,6 +7,7 @@
 - #3033: Add the `muc_grouped_by_domain` option to display MUCs on the same domain in collapsible groups
 - #3300: Adding the maxWait option for `debouncedPruneHistory`
 - #3302: debounce MUC sidebar rendering
+- #3305: New config option [muc_search_service](https://conversejs.org/docs/html/configuration.html#muc-search-service)
 - #3307: Fix inconsistency between browsers on textarea outlines
 - #3337: Correctly display multiline nested quotes
 - Add an occupants filter to the MUC sidebar

+ 11 - 0
docs/source/configuration.rst

@@ -1331,6 +1331,17 @@ automatically be "john". If now john@differentdomain.com tries to join the
 room, his nickname will be "john-2", and if john@somethingelse.com joins, then
 his nickname will be "john-3", and so forth.
 
+
+muc_search_service
+------------------
+
+* Default: ``'api@search.jabber.network'``
+
+The JID of the service that should be used to search for MUCs for auto-complete
+purposes. If this value is set to an empty string, no service will be used and
+the auto-complete feature for adding MUCs will be disabled.
+
+
 muc_send_probes
 ---------------
 

+ 2 - 2
src/plugins/bookmark-views/modals/bookmark-list.js

@@ -6,11 +6,11 @@ import { api } from "@converse/headless";
 
 export default class BookmarkListModal extends BaseModal {
 
-    renderModal () { // eslint-disable-line class-methods-use-this
+    renderModal () {
         return html`<converse-bookmarks></converse-bookmarks>`;
     }
 
-    getModalTitle () { // eslint-disable-line class-methods-use-this
+    getModalTitle () {
         return __('Bookmarks');
     }
 }

+ 1 - 0
src/plugins/muc-views/index.js

@@ -52,6 +52,7 @@ converse.plugins.add('converse-muc-views', {
             'muc_mention_autocomplete_show_avatar': true,
             'muc_roomid_policy': null,
             'muc_roomid_policy_hint': null,
+            'muc_search_service': 'api@search.jabber.network',
             'roomconfig_whitelist': [],
             'show_retraction_warning': true,
             'visible_toolbar_buttons': {

+ 13 - 10
src/plugins/muc-views/modals/templates/add-muc.js

@@ -35,6 +35,7 @@ export default (el) => {
     const label_room_address = muc_domain ? __('Groupchat name') : __('Groupchat address');
     const muc_roomid_policy_error_msg = el.muc_roomid_policy_error_msg;
     const muc_roomid_policy_hint = api.settings.get('muc_roomid_policy_hint');
+    const muc_search_service = api.settings.get('muc_search_service');
     return html`
         <form class="converse-form add-chatroom" @submit=${(ev) => el.openChatRoom(ev)}>
             <div class="form-group">
@@ -42,16 +43,18 @@ export default (el) => {
                 ${muc_roomid_policy_error_msg
                     ? html`<label class="roomid-policy-error">${muc_roomid_policy_error_msg}</label>`
                     : ''}
-                <converse-autocomplete
-                    .getAutoCompleteList=${getAutoCompleteList}
-                    ?autofocus=${true}
-                    min_chars="3"
-                    position="below"
-                    placeholder="${placeholder}"
-                    class="add-muc-autocomplete"
-                    name="chatroom"
-                >
-                </converse-autocomplete>
+                ${muc_search_service
+                    ? html` <converse-autocomplete
+                          .getAutoCompleteList=${getAutoCompleteList}
+                          ?autofocus=${true}
+                          min_chars="3"
+                          position="below"
+                          placeholder="${placeholder}"
+                          class="add-muc-autocomplete"
+                          name="chatroom"
+                      >
+                      </converse-autocomplete>`
+                    : ''}
             </div>
             ${muc_roomid_policy_hint
                 ? html`<div class="form-group">

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

@@ -10,11 +10,12 @@ const rooms_cache = {};
  * @param {string} query
  */
 async function searchRooms (query) {
+    const muc_search_service = api.settings.get('muc_search_service');
     const bare_jid = _converse.session.get('bare_jid');
     const iq = $iq({
         'type': 'get',
         'from': bare_jid,
-        'to': 'api@search.jabber.network'
+        'to': muc_search_service,
     }).c('search', { 'xmlns': Strophe.NS.MUCSEARCH })
         .c('set', { 'xmlns': Strophe.NS.RSM })
             .c('max').t(10).up().up()

+ 8 - 7
src/shared/chat/message-actions.js

@@ -68,15 +68,14 @@ class MessageActions extends CustomElement {
         // This line allows us to pass tests.
         if (!this.model.collection) return '';
 
-        // We want to let the message actions menu drop upwards if we're at the
-        // bottom of the message history, and down otherwise. This is to avoid
-        // the menu disappearing behind the bottom panel (toolbar, textarea etc).
-        // That's difficult to know from state, so we're making an approximation here.
-        const should_drop_up = this.model.collection.length > 2 && this.model === this.model.collection.last();
-
         const buttons = await this.getActionButtons();
         const items = buttons.map(b => MessageActions.getActionsDropdownItem(b));
         if (items.length) {
+            // We want to let the message actions menu drop upwards if we're at the
+            // bottom of the message history, and down otherwise. This is to avoid
+            // the menu disappearing behind the bottom panel (toolbar, textarea etc).
+            // That's difficult to know from state, so we're making an approximation here.
+            const should_drop_up = this.model.collection.length > 3 && this.model === this.model.collection.last();
             return html`<converse-dropdown
                 class="chat-msg__actions ${should_drop_up ? 'dropup dropup--left' : 'dropleft'}"
                 .items=${items}
@@ -107,7 +106,9 @@ class MessageActions extends CustomElement {
         // Then this code can also be put on the model
         const unsent_text = u.ancestor(this, '.chatbox')?.querySelector('.chat-textarea')?.value;
         if (unsent_text && (!currently_correcting || currently_correcting.getMessageText() !== unsent_text)) {
-            const result = await api.confirm(__('You have an unsent message which will be lost if you continue. Are you sure?'));
+            const result = await api.confirm(
+                __('You have an unsent message which will be lost if you continue. Are you sure?')
+            );
             if (!result) return;
         }
         if (currently_correcting !== this.model) {