Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2585 from matrix-org/bwindels/throttlecustomtags
Browse files Browse the repository at this point in the history
Fix: throttle custom tags updating in LLP
  • Loading branch information
bwindels authored Feb 7, 2019
2 parents 5b4ebf3 + c0b9d99 commit b50bfa1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/stores/CustomRoomTagStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import dis from '../dispatcher';
import * as RoomNotifs from '../RoomNotifs';
import RoomListStore from './RoomListStore';
import EventEmitter from 'events';
import { throttle } from "lodash";

const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;

Expand Down Expand Up @@ -49,7 +50,14 @@ class CustomRoomTagStore extends EventEmitter {
super();
// Initialise state
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._setState({tags: this._getUpdatedTags()});
});
Expand Down

0 comments on commit b50bfa1

Please sign in to comment.