Skip to content

Commit

Permalink
Add new config setting muc_search_service
Browse files Browse the repository at this point in the history
Lets you configure which JID to use when searching for MUCs for
auto-complete purposes.

Fixes #3305
  • Loading branch information
jcbrand committed Mar 5, 2024
1 parent b6626ba commit 674fdd5
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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
- Add an occupants filter to the MUC sidebar
- Fix: MUC occupant list does not sort itself on nicknames or roles changes
Expand Down
11 changes: 11 additions & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,17 @@ automatically be "john". If now [email protected] tries to join the
room, his nickname will be "john-2", and if [email protected] joins, then
his nickname will be "john-3", and so forth.


muc_search_service
------------------

* Default: ``'[email protected]'``

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

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/bookmark-views/modals/bookmark-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/muc-views/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': '[email protected]',
'roomconfig_whitelist': [],
'show_retraction_warning': true,
'visible_toolbar_buttons': {
Expand Down
23 changes: 13 additions & 10 deletions src/plugins/muc-views/modals/templates/add-muc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,26 @@ 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">
<label for="chatroom">${label_room_address}:</label>
${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">
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/muc-views/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': '[email protected]'
'to': muc_search_service,
}).c('search', { 'xmlns': Strophe.NS.MUCSEARCH })
.c('set', { 'xmlns': Strophe.NS.RSM })
.c('max').t(10).up().up()
Expand Down
15 changes: 9 additions & 6 deletions src/shared/chat/message-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ class MessageActions extends CustomElement {
}

async renderActions () {
// 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();
if (!this.model.collection) return '';

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 > 2 && this.model === this.model.collection.last();
return html`<converse-dropdown
class="chat-msg__actions ${should_drop_up ? 'dropup dropup--left' : 'dropleft'}"
.items=${items}
Expand Down Expand Up @@ -88,7 +89,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) {
Expand Down

0 comments on commit 674fdd5

Please sign in to comment.