Merge pull request #4260 from matrix-org/bwindels/filtercanon-altaliases

Fix: filter room list (again) by canonical and alternative aliases
pull/21833/head
Bruno Windels 2020-03-23 12:48:03 +00:00 committed by GitHub
commit cef1fd55b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -647,8 +647,13 @@ export default createReactClass({
// case insensitive if room name includes filter, // case insensitive if room name includes filter,
// or if starts with `#` and one of room's aliases starts with filter // or if starts with `#` and one of room's aliases starts with filter
return list.filter((room) => { return list.filter((room) => {
if (filter[0] === "#" && room.getAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))) { if (filter[0] === "#") {
return true; if (room.getCanonicalAlias() && room.getCanonicalAlias().toLowerCase().startsWith(lcFilter)) {
return true;
}
if (room.getAltAliases().some((alias) => alias.toLowerCase().startsWith(lcFilter))) {
return true;
}
} }
return room.name && utils.removeHiddenChars(room.name.toLowerCase()).toLowerCase().includes(fuzzyFilter); return room.name && utils.removeHiddenChars(room.name.toLowerCase()).toLowerCase().includes(fuzzyFilter);
}); });