Style changes and improvements in autocomplete
This commit is contained in:
parent
b9d7743e5a
commit
4af983ed90
10 changed files with 135 additions and 93 deletions
|
@ -4,20 +4,22 @@ import MatrixClientPeg from '../MatrixClientPeg';
|
|||
|
||||
const ROOM_REGEX = /@[^\s]*/g;
|
||||
|
||||
let instance = null;
|
||||
|
||||
export default class UserProvider extends AutocompleteProvider {
|
||||
constructor() {
|
||||
super();
|
||||
this.users = [];
|
||||
}
|
||||
|
||||
getCompletions(query: String) {
|
||||
let client = MatrixClientPeg.get();
|
||||
let completions = [];
|
||||
const matches = query.match(ROOM_REGEX);
|
||||
if(!!matches) {
|
||||
const command = matches[0];
|
||||
completions = client.getUsers().map(user => {
|
||||
completions = this.users.map(user => {
|
||||
return {
|
||||
title: user.displayName,
|
||||
title: user.displayName || user.userId,
|
||||
description: user.userId
|
||||
};
|
||||
});
|
||||
|
@ -28,4 +30,15 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
getName() {
|
||||
return 'Users';
|
||||
}
|
||||
|
||||
setUserList(users) {
|
||||
console.log('setUserList');
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
static getInstance(): UserProvider {
|
||||
if(instance == null)
|
||||
instance = new UserProvider();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue