Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b3d8292

Browse files
committed
feat: use canonical room alias for room completion
1 parent 73b726e commit b3d8292

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/autocomplete/Components.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function TextualCompletion({
1313
<div style={{width: '100%'}}>
1414
<span>{title}</span>
1515
<em>{subtitle}</em>
16-
<span style={{color: 'gray'}}>{description}</span>
16+
<span style={{color: 'gray', float: 'right'}}>{description}</span>
1717
</div>
1818
);
1919
}

src/autocomplete/RoomProvider.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Q from 'q';
44
import MatrixClientPeg from '../MatrixClientPeg';
55
import Fuse from 'fuse.js';
66
import {TextualCompletion} from './Components';
7+
import {getDisplayAliasForRoom} from '../MatrixTools';
78

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

@@ -27,16 +28,18 @@ export default class RoomProvider extends AutocompleteProvider {
2728
// the only reason we need to do this is because Fuse only matches on properties
2829
this.fuse.set(client.getRooms().filter(room => !!room).map(room => {
2930
return {
31+
room: room,
3032
name: room.name,
3133
roomId: room.roomId,
3234
aliases: room.getAliases(),
3335
};
3436
}));
3537
completions = this.fuse.search(command[0]).map(room => {
38+
let displayAlias = getDisplayAliasForRoom(room.room) || room.roomId;
3639
return {
37-
completion: room.roomId,
40+
completion: displayAlias,
3841
component: (
39-
<TextualCompletion title={room.name} subtitle={room.roomId} />
42+
<TextualCompletion title={room.name} description={displayAlias} />
4043
),
4144
range,
4245
};

0 commit comments

Comments
 (0)