xhr_user_search_url
fixes after some real world testing
This commit is contained in:
parent
e21f14f4bd
commit
5e8843e8bd
@ -153,16 +153,21 @@
|
|||||||
afterRender () {
|
afterRender () {
|
||||||
const input_el = this.el.querySelector('input[name="jid"]');
|
const input_el = this.el.querySelector('input[name="jid"]');
|
||||||
if (_converse.xhr_user_search_url && _.isString(_converse.xhr_user_search_url)) {
|
if (_converse.xhr_user_search_url && _.isString(_converse.xhr_user_search_url)) {
|
||||||
const awesomplete = new Awesomplete(input_el, {'list': [], 'minChars': 2});
|
const awesomplete = new Awesomplete(input_el, {'list': []});
|
||||||
const xhr = new window.XMLHttpRequest();
|
const xhr = new window.XMLHttpRequest();
|
||||||
// `open` must be called after `onload` for
|
// `open` must be called after `onload` for mock/testing purposes.
|
||||||
// mock/testing purposes.
|
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
awesomplete.list = JSON.parse(xhr.responseText).map((i) => i.jid);
|
if (xhr.responseText) {
|
||||||
awesomplete.evaluate();
|
awesomplete.list = JSON.parse(xhr.responseText).map((i) => {
|
||||||
|
return {'label': i.fullname, 'value': i.jid};
|
||||||
|
});
|
||||||
|
awesomplete.evaluate();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xhr.open("GET", _converse.xhr_user_search_url, true);
|
input_el.addEventListener('input', _.debounce(() => {
|
||||||
input_el.addEventListener('input', _.debounce(() => xhr.send()), 100, {'leading': true});
|
xhr.open("GET", `${_converse.xhr_user_search_url}?q=${input_el.value}`, true);
|
||||||
|
xhr.send()
|
||||||
|
} , 500));
|
||||||
} else {
|
} else {
|
||||||
const list = _.uniq(_converse.roster.map((item) => Strophe.getDomainFromJid(item.get('jid'))));
|
const list = _.uniq(_converse.roster.map((item) => Strophe.getDomainFromJid(item.get('jid'))));
|
||||||
new Awesomplete(input_el, {
|
new Awesomplete(input_el, {
|
||||||
|
Loading…
Reference in New Issue
Block a user