From 66cd8475b5096872eb136f86a7900ca3e4a1e768 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 7 Jan 2019 17:46:32 -0700 Subject: [PATCH] Don't reset cached room list values when they are falsey `unread` and `unread-muted` store booleans in the cache, and can easily be `false`. Without this patch, both of those cached types would be cleared from the object where a later call to `getRoomState` would try and re-populate them. `getRoomState` is supposed to use the cache where possible to avoid making the more expensive calls required to calculate those booleans. On my account in a test environment, this brings the `generateRoomLists` execution time down from ~250ms to just ~30ms. This still does not solve the whole issue, but should solve the more common case of performance woes for people. --- src/stores/RoomListStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index af6a8cc991..ed0974b0e4 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -277,7 +277,7 @@ class RoomListStore extends Store { const roomCache = this._state.roomCache; if (!roomCache[roomId]) roomCache[roomId] = {}; - if (value) roomCache[roomId][type] = value; + if (typeof value !== "undefined") roomCache[roomId][type] = value; else delete roomCache[roomId][type]; this._setState({roomCache});