mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
throttle custom tags updating in LLP
This commit is contained in:
parent
80731a9de4
commit
35d9c02ecd
1 changed files with 9 additions and 1 deletions
|
@ -17,6 +17,7 @@ import dis from '../dispatcher';
|
||||||
import * as RoomNotifs from '../RoomNotifs';
|
import * as RoomNotifs from '../RoomNotifs';
|
||||||
import RoomListStore from './RoomListStore';
|
import RoomListStore from './RoomListStore';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
|
import * as _ from "lodash";
|
||||||
|
|
||||||
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;
|
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;
|
||||||
|
|
||||||
|
@ -49,7 +50,14 @@ class CustomRoomTagStore extends EventEmitter {
|
||||||
super();
|
super();
|
||||||
// Initialise state
|
// Initialise state
|
||||||
this._state = {tags: {}};
|
this._state = {tags: {}};
|
||||||
|
// as RoomListStore gets updated by every timeline event
|
||||||
|
// throttle this to only run every 500ms
|
||||||
|
this._getUpdatedTags = _.throttle(
|
||||||
|
this._getUpdatedTags, 500, {
|
||||||
|
leading: true,
|
||||||
|
trailing: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
this._roomListStoreToken = RoomListStore.addListener(() => {
|
this._roomListStoreToken = RoomListStore.addListener(() => {
|
||||||
this._setState({tags: this._getUpdatedTags()});
|
this._setState({tags: this._getUpdatedTags()});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue