Match new room list's text search to old room list
Fixes https://github.com/vector-im/riot-web/issues/14042
This commit is contained in:
parent
94f52c4ee2
commit
f8828014f1
1 changed files with 12 additions and 2 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { FILTER_CHANGED, FilterPriority, IFilterCondition } from "./IFilterCondition";
|
import { FILTER_CHANGED, FilterPriority, IFilterCondition } from "./IFilterCondition";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
|
import { removeHiddenChars } from "matrix-js-sdk/src/utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A filter condition for the room list which reveals rooms of a particular
|
* A filter condition for the room list which reveals rooms of a particular
|
||||||
|
@ -45,7 +46,16 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio
|
||||||
}
|
}
|
||||||
|
|
||||||
public isVisible(room: Room): boolean {
|
public isVisible(room: Room): boolean {
|
||||||
// TODO: Improve this filter to include aliases and such
|
const lcFilter = this.search.toLowerCase();
|
||||||
return room.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0;
|
if (this.search[0] === '#') {
|
||||||
|
// Try and find rooms by alias
|
||||||
|
if (room.getCanonicalAlias() && room.getCanonicalAlias().toLowerCase().startsWith(lcFilter)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (room.getAltAliases().some(a => a.toLowerCase().startsWith(lcFilter))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return room.name && removeHiddenChars(room.name).toLowerCase().includes(lcFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue