From 35d9c02ecd4108f1740a2c62c0c9120448345f07 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 7 Feb 2019 15:28:22 +0000 Subject: [PATCH 1/2] throttle custom tags updating in LLP --- src/stores/CustomRoomTagStore.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/stores/CustomRoomTagStore.js b/src/stores/CustomRoomTagStore.js index 3e109aef2d..ddcb30de78 100644 --- a/src/stores/CustomRoomTagStore.js +++ b/src/stores/CustomRoomTagStore.js @@ -17,6 +17,7 @@ import dis from '../dispatcher'; import * as RoomNotifs from '../RoomNotifs'; import RoomListStore from './RoomListStore'; import EventEmitter from 'events'; +import * as _ from "lodash"; 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(); // 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()}); }); From c0b9d9938576ce4a852f89866399259cf9abb515 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 7 Feb 2019 16:03:12 +0000 Subject: [PATCH 2/2] only import throttle fn --- src/stores/CustomRoomTagStore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stores/CustomRoomTagStore.js b/src/stores/CustomRoomTagStore.js index ddcb30de78..9795abadc6 100644 --- a/src/stores/CustomRoomTagStore.js +++ b/src/stores/CustomRoomTagStore.js @@ -17,7 +17,7 @@ import dis from '../dispatcher'; import * as RoomNotifs from '../RoomNotifs'; import RoomListStore from './RoomListStore'; import EventEmitter from 'events'; -import * as _ from "lodash"; +import { throttle } from "lodash"; const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/; @@ -52,7 +52,7 @@ class CustomRoomTagStore extends EventEmitter { this._state = {tags: {}}; // as RoomListStore gets updated by every timeline event // throttle this to only run every 500ms - this._getUpdatedTags = _.throttle( + this._getUpdatedTags = throttle( this._getUpdatedTags, 500, { leading: true, trailing: true,