room, user, ddg autocomplete providers (wip)
This commit is contained in:
parent
0df201c483
commit
4bc8ec3e6d
9 changed files with 163 additions and 19 deletions
31
src/autocomplete/UserProvider.js
Normal file
31
src/autocomplete/UserProvider.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import AutocompleteProvider from './AutocompleteProvider';
|
||||
import Q from 'q';
|
||||
import MatrixClientPeg from '../MatrixClientPeg';
|
||||
|
||||
const ROOM_REGEX = /@[^\s]*/g;
|
||||
|
||||
export default class UserProvider extends AutocompleteProvider {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
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 => {
|
||||
return {
|
||||
title: user.displayName,
|
||||
description: user.userId
|
||||
};
|
||||
});
|
||||
}
|
||||
return Q.when(completions);
|
||||
}
|
||||
|
||||
getName() {
|
||||
return 'Users';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue