diff --git a/src/stores/room-list/filters/NameFilterCondition.ts b/src/stores/room-list/filters/NameFilterCondition.ts index 6014a122f8..88edaecfb6 100644 --- a/src/stores/room-list/filters/NameFilterCondition.ts +++ b/src/stores/room-list/filters/NameFilterCondition.ts @@ -18,6 +18,7 @@ import { Room } from "matrix-js-sdk/src/models/room"; import { FILTER_CHANGED, FilterPriority, IFilterCondition } from "./IFilterCondition"; import { EventEmitter } from "events"; import { removeHiddenChars } from "matrix-js-sdk/src/utils"; +import { throttle } from "lodash"; /** * A filter condition for the room list which reveals rooms of a particular @@ -41,9 +42,13 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio public set search(val: string) { this._search = val; - this.emit(FILTER_CHANGED); + this.callUpdate(); } + private callUpdate = throttle(() => { + this.emit(FILTER_CHANGED); + }, 200, {trailing: true, leading: true}); + public isVisible(room: Room): boolean { const lcFilter = this.search.toLowerCase(); if (this.search[0] === '#') {