Skip to content
Permalink
Browse files

feat: use canonical room alias for room completion

  • Loading branch information
aviraldg committed Jul 4, 2016
1 parent 73b726e commit b3d82921137a28edf5b511390c5d6bc34ee402ff
Showing with 6 additions and 3 deletions.
  1. +1 −1 src/autocomplete/Components.js
  2. +5 −2 src/autocomplete/RoomProvider.js
@@ -13,7 +13,7 @@ export function TextualCompletion({
<div style={{width: '100%'}}>
<span>{title}</span>
<em>{subtitle}</em>
<span style={{color: 'gray'}}>{description}</span>
<span style={{color: 'gray', float: 'right'}}>{description}</span>
</div>
);
}
@@ -4,6 +4,7 @@ import Q from 'q';
import MatrixClientPeg from '../MatrixClientPeg';
import Fuse from 'fuse.js';
import {TextualCompletion} from './Components';
import {getDisplayAliasForRoom} from '../MatrixTools';

const ROOM_REGEX = /(?=#)([^\s]*)/g;

@@ -27,16 +28,18 @@ export default class RoomProvider extends AutocompleteProvider {
// the only reason we need to do this is because Fuse only matches on properties
this.fuse.set(client.getRooms().filter(room => !!room).map(room => {
return {
room: room,
name: room.name,
roomId: room.roomId,
aliases: room.getAliases(),
};
}));
completions = this.fuse.search(command[0]).map(room => {
let displayAlias = getDisplayAliasForRoom(room.room) || room.roomId;
return {
completion: room.roomId,
completion: displayAlias,
component: (
<TextualCompletion title={room.name} subtitle={room.roomId} />
<TextualCompletion title={room.name} description={displayAlias} />
),
range,
};

0 comments on commit b3d8292

Please sign in to comment.
You can’t perform that action at this time.