Merge pull request #2722 from matrix-org/travis/misc-roomlist

Misc room list improvements & invite fix
This commit is contained in:
Travis Ralston 2019-02-28 15:13:06 -07:00 committed by GitHub
commit 8d7837829e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,6 +133,8 @@ class RoomListStore extends Store {
const logicallyReady = this._matrixClient && this._state.ready; const logicallyReady = this._matrixClient && this._state.ready;
switch (payload.action) { switch (payload.action) {
case 'setting_updated': { case 'setting_updated': {
if (!logicallyReady) break;
if (payload.settingName === 'RoomList.orderByImportance') { if (payload.settingName === 'RoomList.orderByImportance') {
this.updateSortingAlgorithm(payload.newValue === true ? ALGO_IMPORTANCE : ALGO_RECENT); this.updateSortingAlgorithm(payload.newValue === true ? ALGO_IMPORTANCE : ALGO_RECENT);
} else if (payload.settingName === 'feature_custom_tags') { } else if (payload.settingName === 'feature_custom_tags') {
@ -147,6 +149,10 @@ class RoomListStore extends Store {
break; 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._setState({tagsEnabled: SettingsStore.isFeatureEnabled("feature_custom_tags")});
this._matrixClient = payload.matrixClient; this._matrixClient = payload.matrixClient;
@ -471,7 +477,9 @@ class RoomListStore extends Store {
room, category, this._state.lists[key], listsClone[key], lastTimestamp); room, category, this._state.lists[key], listsClone[key], lastTimestamp);
if (!pushedEntry) { 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}); listsClone[key].push({room, category});
insertedIntoTags.push(key); insertedIntoTags.push(key);
} else { } else {
@ -523,15 +531,6 @@ class RoomListStore extends Store {
const dmRoomMap = DMRoomMap.shared(); 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) => { this._matrixClient.getRooms().forEach((room) => {
const myUserId = this._matrixClient.getUserId(); const myUserId = this._matrixClient.getUserId();
const membership = room.getMyMembership(); const membership = room.getMyMembership();
@ -547,7 +546,7 @@ class RoomListStore extends Store {
tagNames = tagNames.filter((t) => { tagNames = tagNames.filter((t) => {
// Speed optimization: Avoid hitting the SettingsStore at all costs by making it the // Speed optimization: Avoid hitting the SettingsStore at all costs by making it the
// last condition possible. // last condition possible.
return lists[t] !== undefined || (!t.startsWith('m.') && isCustomTagsEnabled()); return lists[t] !== undefined || (!t.startsWith('m.') && this._state.tagsEnabled);
}); });
if (tagNames.length) { if (tagNames.length) {