Commit c32070c9 authored by JC Brand's avatar JC Brand

Autocomplete fixes

- Fixes #1575. Height not properly set on MUC invitation list
- Add new configuration setting: `muc_mention_autocomplete_min_chars`
- Bugfix. `min_chars` setting for MUC mentions wasn't having an effect
parent 36549bf6
......@@ -18,11 +18,12 @@
- Message deduplication bugfixes and improvements
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus).
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus)
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks)
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit)
- New config option [singleton](https://conversejs.org/docs/html/configuration.html#singleton).
- New config option [singleton](https://conversejs.org/docs/html/configuration.html#singleton)
- New config option [muc_mention_autocomplete_min_chars](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-min-chars)
By setting this option to `false` and `view_mode` to `'embedded'`, it's now possible to
"embed" the full app and not just a single chat. To embed just a single chat, it's now
necessary to explicitly set `singleton` to `true`.
......@@ -43,6 +44,7 @@
- #1554: Room auto-configuration broke if the config form contained fields with type `fixed`
- #1558: `this.get` is not a function error when `forward_messages` is set to `true`.
- #1572: In `fullscreen` view mode the top is cut off on iOS
- #1575: MUC invitation autocomplete list doesn't appear
- #1576: Converse gets stuck with spinner when logging out with `auto_login` set to `true`
- #1579: Trim spaces at the beginning and end of a JID (when adding contact)
- #1586: Not possible to kick someone with a space in their nickname
......
......@@ -837,6 +837,14 @@ VCard is taken, and if that is not set but `muc_nickname_from_jid`_ is set to
If no nickame value is found, then an error will be raised.
muc_mention_autocomplete_min_chars
-----------------------------------
* Default: ``0``
The number of characters that need to be entered before the auto-complete list
of matching nicknames is shown.
message_archiving
-----------------
......
......@@ -325,6 +325,7 @@ converse.plugins.add("converse-autocomplete", {
ev.keyCode === _converse.keycodes.UP_ARROW ||
ev.keyCode === _converse.keycodes.DOWN_ARROW
);
if (!this.auto_evaluate && !this.auto_completing || selecting) {
return;
}
......@@ -335,14 +336,15 @@ converse.plugins.add("converse-autocomplete", {
}
let value = this.match_current_word ? u.getCurrentWord(this.input) : this.input.value;
let ignore_min_chars = false;
if (this.ac_triggers.includes(value[0]) && !this.include_triggers.includes(ev.key)) {
ignore_min_chars = true;
value = value.slice('1');
const contains_trigger = this.ac_triggers.includes(value[0]);
if (contains_trigger) {
this.auto_completing = true;
if (!this.include_triggers.includes(ev.key)) {
value = value.slice('1');
}
}
if ((value.length >= this.min_chars) || ignore_min_chars) {
if ((contains_trigger || value.length) && value.length >= this.min_chars) {
this.index = -1;
// Populate list with options that match
this.ul.innerHTML = "";
......@@ -364,7 +366,9 @@ converse.plugins.add("converse-autocomplete", {
}
} else {
this.close({'reason': 'nomatches'});
this.auto_completing = false;
if (!contains_trigger) {
this.auto_completing = false;
}
}
}
}
......
......@@ -105,6 +105,7 @@ converse.plugins.add('converse-muc-views', {
'muc_disable_slash_commands': false,
'muc_show_join_leave': true,
'muc_show_join_leave_status': true,
'muc_mention_autocomplete_min_chars': 0,
'roomconfig_whitelist': [],
'visible_toolbar_buttons': {
'toggle_occupants': true
......@@ -570,7 +571,7 @@ converse.plugins.add('converse-muc-views', {
this.mention_auto_complete = new _converse.AutoComplete(this.el, {
'auto_first': true,
'auto_evaluate': false,
'min_chars': 1,
'min_chars': _converse.muc_mention_autocomplete_min_chars,
'match_current_word': true,
'list': () => this.getAutoCompleteList(),
'filter': _converse.FILTER_STARTSWITH,
......@@ -1859,10 +1860,9 @@ converse.plugins.add('converse-muc-views', {
'list': list
});
this.invite_auto_complete.on('suggestion-box-selectcomplete', ev => this.promptForInvite(ev));
this.invite_auto_complete.ul.setAttribute(
'style',
`max-height: calc(${this.el.offsetHeight}px - 80px);`
);
this.invite_auto_complete.on('suggestion-box-open', ev => {
this.invite_auto_complete.ul.setAttribute('style', `max-height: calc(${this.el.offsetHeight}px - 80px);`);
});
}
});
......
......@@ -984,7 +984,7 @@ converse.plugins.add('converse-chatboxes', {
},
onChatBoxesFetched (collection) {
/* Show chat boxes upon receiving them from sessionStorage */
/* Show chat boxes upon receiving them from storage */
collection.filter(c => !c.isValid()).forEach(c => c.destroy());
collection.forEach(c => c.maybeShow());
/**
......
......@@ -2000,7 +2000,7 @@ converse.plugins.add('converse-muc', {
* JIDs of the chatroom(s) to create
* @param {object} [attrs] attrs The room attributes
*/
'create' (jids, attrs) {
create (jids, attrs) {
if (_.isString(attrs)) {
attrs = {'nick': attrs};
} else if (_.isUndefined(attrs)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment