From 6a38833a2b7a7589fe4d6643abeabd859bf75c9b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 21 Jul 2020 14:12:58 -0600 Subject: [PATCH] Ensure incremental updates to the ImportanceAlgorithm trigger A-Z order Fixes https://github.com/vector-im/riot-web/issues/14475 Background: Sticky rooms are actually a pair of lies to the underlying algorithm as a combination of REMOVE_ROOM/NEW_ROOM calls so they don't get considered as needing to be sorted. When a room is added under the importance algorithm, it is expected that the category it is being added to will be re-sorted to account for the change, however we weren't doing that since we optimized the NewRoom path to be a splice operation. --- .../room-list/algorithms/list-ordering/ImportanceAlgorithm.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts index e3e0cdcac4..8427663ad4 100644 --- a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts +++ b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts @@ -123,6 +123,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { const category = this.getRoomCategory(room); this.alterCategoryPositionBy(category, 1, this.indices); this.cachedOrderedRooms.splice(this.indices[category], 0, room); // splice in the new room (pre-adjusted) + await this.sortCategory(category); } else if (cause === RoomUpdateCause.RoomRemoved) { const roomIdx = this.getRoomIndex(room); if (roomIdx === -1) {