Merge pull request #4962 from matrix-org/travis/room-list/leave-fix

Ensure tag changes (leaving rooms) causes rooms to move between lists
pull/21833/head
Travis Ralston 2020-07-13 12:44:23 -06:00 committed by GitHub
commit 1f57b85b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -698,8 +698,8 @@ export class Algorithm extends EventEmitter {
}
}
let didTagChange = false;
if (cause === RoomUpdateCause.PossibleTagChange) {
let didTagChange = false;
const oldTags = this.roomIdsToTags[room.roomId] || [];
const newTags = this.getTagsForRoom(room);
const diff = arrayDiff(oldTags, newTags);
@ -713,6 +713,11 @@ export class Algorithm extends EventEmitter {
if (!algorithm) throw new Error(`No algorithm for ${rmTag}`);
await algorithm.handleRoomUpdate(room, RoomUpdateCause.RoomRemoved);
this.cachedRooms[rmTag] = algorithm.orderedRooms;
// Later on we won't update the filtered rooms or sticky room for removed
// tags, so do so now.
this.recalculateFilteredRoomsForTag(rmTag);
this.recalculateStickyRoom(rmTag);
}
for (const addTag of diff.added) {
if (!window.mx_QuietRoomListLogging) {
@ -812,7 +817,7 @@ export class Algorithm extends EventEmitter {
return false;
}
let changed = false;
let changed = didTagChange;
for (const tag of tags) {
const algorithm: OrderingAlgorithm = this.algorithms[tag];
if (!algorithm) throw new Error(`No algorithm for ${tag}`);