From b1e16e9f4967cd83649a69b3345ec6845290ed9d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Feb 2019 13:55:20 -0700 Subject: [PATCH 1/3] Fix stacktrace when starting riot up with rooms Settings can trigger before we're ready, so don't generate the room list. This also includes a comment to signify to future people that we need to track settings still. --- src/stores/RoomListStore.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index ca349f00ba..292f7beb98 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -133,6 +133,8 @@ class RoomListStore extends Store { const logicallyReady = this._matrixClient && this._state.ready; switch (payload.action) { case 'setting_updated': { + if (!logicallyReady) break; + if (payload.settingName === 'RoomList.orderByImportance') { this.updateSortingAlgorithm(payload.newValue === true ? ALGO_IMPORTANCE : ALGO_RECENT); } else if (payload.settingName === 'feature_custom_tags') { @@ -147,6 +149,10 @@ class RoomListStore extends Store { break; } + // Always ensure that we set any state needed for settings here. It is possible that + // setting updates trigger on startup before we are ready to sync, so we want to make + // sure that the right state is in place before we actually react to those changes. + this._setState({tagsEnabled: SettingsStore.isFeatureEnabled("feature_custom_tags")}); this._matrixClient = payload.matrixClient; From 872cdaa9b35e86fc71a56ecee143015ecc772ca6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Feb 2019 14:03:03 -0700 Subject: [PATCH 2/3] Use the already available state for checking if custom tags are enabled --- src/stores/RoomListStore.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index 292f7beb98..a4138fcf01 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -529,15 +529,6 @@ class RoomListStore extends Store { const dmRoomMap = DMRoomMap.shared(); - // Speed optimization: Hitting the SettingsStore is expensive, so avoid that at all costs. - let _isCustomTagsEnabled = null; - const isCustomTagsEnabled = () => { - if (_isCustomTagsEnabled === null) { - _isCustomTagsEnabled = SettingsStore.isFeatureEnabled("feature_custom_tags"); - } - return _isCustomTagsEnabled; - }; - this._matrixClient.getRooms().forEach((room) => { const myUserId = this._matrixClient.getUserId(); const membership = room.getMyMembership(); @@ -553,7 +544,7 @@ class RoomListStore extends Store { tagNames = tagNames.filter((t) => { // Speed optimization: Avoid hitting the SettingsStore at all costs by making it the // last condition possible. - return lists[t] !== undefined || (!t.startsWith('m.') && isCustomTagsEnabled()); + return lists[t] !== undefined || (!t.startsWith('m.') && this._state.tagsEnabled); }); if (tagNames.length) { From 805676a511704baadc6f20ae886495d95bb2c2ae Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 28 Feb 2019 14:02:39 -0700 Subject: [PATCH 3/3] Don't lose invites when multiple are pending --- src/stores/RoomListStore.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index a4138fcf01..e9ac33b506 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -477,7 +477,9 @@ class RoomListStore extends Store { room, category, this._state.lists[key], listsClone[key], lastTimestamp); if (!pushedEntry) { - if (listsClone[key].length === 0) { + // Special case invites: they don't really have timelines and can easily get lost when + // the user has multiple pending invites. Pushing them is the least worst option. + if (listsClone[key].length === 0 || key === "im.vector.fake.invite") { listsClone[key].push({room, category}); insertedIntoTags.push(key); } else {