Style changes and improvements in autocomplete
This commit is contained in:
parent
b9d7743e5a
commit
4af983ed90
10 changed files with 135 additions and 93 deletions
|
@ -1,9 +1,12 @@
|
|||
import AutocompleteProvider from './AutocompleteProvider';
|
||||
import Q from 'q';
|
||||
import MatrixClientPeg from '../MatrixClientPeg';
|
||||
import Fuse from 'fuse.js';
|
||||
|
||||
const ROOM_REGEX = /(?=#)[^\s]*/g;
|
||||
|
||||
let instance = null;
|
||||
|
||||
export default class RoomProvider extends AutocompleteProvider {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -13,8 +16,8 @@ export default class RoomProvider extends AutocompleteProvider {
|
|||
let client = MatrixClientPeg.get();
|
||||
let completions = [];
|
||||
const matches = query.match(ROOM_REGEX);
|
||||
if(!!matches) {
|
||||
const command = matches[0];
|
||||
const command = matches && matches[0];
|
||||
if(command) {
|
||||
completions = client.getRooms().map(room => {
|
||||
return {
|
||||
title: room.name,
|
||||
|
@ -28,4 +31,11 @@ export default class RoomProvider extends AutocompleteProvider {
|
|||
getName() {
|
||||
return 'Rooms';
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if(instance == null)
|
||||
instance = new RoomProvider();
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue