mirror of https://github.com/vector-im/riot-web
feat: use canonical room alias for room completion
parent
73b726e5fb
commit
b3d8292113
|
@ -13,7 +13,7 @@ export function TextualCompletion({
|
||||||
<div style={{width: '100%'}}>
|
<div style={{width: '100%'}}>
|
||||||
<span>{title}</span>
|
<span>{title}</span>
|
||||||
<em>{subtitle}</em>
|
<em>{subtitle}</em>
|
||||||
<span style={{color: 'gray'}}>{description}</span>
|
<span style={{color: 'gray', float: 'right'}}>{description}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Q from 'q';
|
||||||
import MatrixClientPeg from '../MatrixClientPeg';
|
import MatrixClientPeg from '../MatrixClientPeg';
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
import {TextualCompletion} from './Components';
|
import {TextualCompletion} from './Components';
|
||||||
|
import {getDisplayAliasForRoom} from '../MatrixTools';
|
||||||
|
|
||||||
const ROOM_REGEX = /(?=#)([^\s]*)/g;
|
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
|
// 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 => {
|
this.fuse.set(client.getRooms().filter(room => !!room).map(room => {
|
||||||
return {
|
return {
|
||||||
|
room: room,
|
||||||
name: room.name,
|
name: room.name,
|
||||||
roomId: room.roomId,
|
roomId: room.roomId,
|
||||||
aliases: room.getAliases(),
|
aliases: room.getAliases(),
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
completions = this.fuse.search(command[0]).map(room => {
|
completions = this.fuse.search(command[0]).map(room => {
|
||||||
|
let displayAlias = getDisplayAliasForRoom(room.room) || room.roomId;
|
||||||
return {
|
return {
|
||||||
completion: room.roomId,
|
completion: displayAlias,
|
||||||
component: (
|
component: (
|
||||||
<TextualCompletion title={room.name} subtitle={room.roomId} />
|
<TextualCompletion title={room.name} description={displayAlias} />
|
||||||
),
|
),
|
||||||
range,
|
range,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue