apply roomlist searchFilter to aliases if it begins with a `#`

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2018-06-13 09:51:35 +01:00
parent e858cf3bcb
commit 41be46a712
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
1 changed files with 8 additions and 1 deletions

View File

@ -105,8 +105,15 @@ var RoomSubList = React.createClass({
applySearchFilter: function(list, filter) {
if (filter === "") return list;
const lcFilter = filter.toLowerCase();
return list.filter((room) => {
return room.name && room.name.toLowerCase().indexOf(filter.toLowerCase()) >= 0
if (room.name && room.name.toLowerCase().includes(lcFilter)) return true;
// only apply search filter to aliases if it looks like an alias (starts with `#`)
// to prevent loads of false positives with server names, e.g `matrix`
if (filter[0] === '#' && room.getAliases().some((alias) => {
return alias.toLowerCase().startsWith(lcFilter);
})) return true;
return false;
});
},