Apply a throttle to filter condition updates
This commit is contained in:
parent
517c93a7d5
commit
a15aae4daf
1 changed files with 6 additions and 1 deletions
|
@ -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] === '#') {
|
||||
|
|
Loading…
Reference in a new issue