mirror of https://github.com/vector-im/riot-web
Initial work on improving invite dialog
parent
2b91b0d9c4
commit
b41787c335
|
@ -167,11 +167,21 @@ module.exports = React.createClass({
|
||||||
const query = ev.target.value;
|
const query = ev.target.value;
|
||||||
let queryList = [];
|
let queryList = [];
|
||||||
|
|
||||||
|
if (query.length < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.queryChangedDebouncer) {
|
||||||
|
clearTimeout(this.queryChangedDebouncer);
|
||||||
|
}
|
||||||
|
this.queryChangedDebouncer = setTimeout(() => {
|
||||||
// Only do search if there is something to search
|
// Only do search if there is something to search
|
||||||
if (query.length > 0 && query != '@') {
|
if (query.length > 0 && query != '@') {
|
||||||
// filter the known users list
|
// filter the known users list
|
||||||
queryList = this._userList.filter((user) => {
|
queryList = this._userList.filter((user) => {
|
||||||
return this._matches(query, user);
|
return this._matches(query, user);
|
||||||
|
}).sort((userA, userB) => {
|
||||||
|
return this._sortedMatches(query, userA, userB);
|
||||||
}).map((user) => {
|
}).map((user) => {
|
||||||
// Return objects, structure of which is defined
|
// Return objects, structure of which is defined
|
||||||
// by InviteAddressType
|
// by InviteAddressType
|
||||||
|
@ -201,11 +211,11 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
queryList: queryList,
|
queryList: queryList,
|
||||||
error: false,
|
error: false,
|
||||||
});
|
});
|
||||||
|
}, 200);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDismissed: function(index) {
|
onDismissed: function(index) {
|
||||||
|
@ -349,8 +359,8 @@ module.exports = React.createClass({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct prefix matches
|
// positional matches
|
||||||
if (name.indexOf(query) === 0 || uid.indexOf(query) === 0) {
|
if (name.indexOf(query) !== -1 || uid.indexOf(query) !== -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,6 +384,16 @@ module.exports = React.createClass({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_sortedMatches: function(query, userA, userB) {
|
||||||
|
if (userA.displayName.startsWith(query) || userA.userId.startsWith(query)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (userA.displayName.length === query.length) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
_isOnInviteList: function(uid) {
|
_isOnInviteList: function(uid) {
|
||||||
for (let i = 0; i < this.state.inviteList.length; i++) {
|
for (let i = 0; i < this.state.inviteList.length; i++) {
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue