Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7f66198

Browse files
authored
Merge pull request #4175 from matrix-org/travis/room-list-updates
Ensure the room list always triggers updates on itself
2 parents 5da13ea + 8e3fea9 commit 7f66198

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/stores/RoomListStore.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ class RoomListStore extends Store {
372372
_slotRoomIntoList(room, category, tag, existingEntries, newList, lastTimestampFn) {
373373
const targetCategoryIndex = CATEGORY_ORDER.indexOf(category);
374374

375+
let categoryComparator = (a, b) => lastTimestampFn(a.room) >= lastTimestampFn(b.room);
376+
const sortAlgorithm = getListAlgorithm(tag, this._state.algorithm);
377+
if (sortAlgorithm === ALGO_RECENT) {
378+
categoryComparator = (a, b) => this._recentsComparator(a, b, lastTimestampFn);
379+
} else if (sortAlgorithm === ALGO_ALPHABETIC) {
380+
categoryComparator = (a, b) => this._lexicographicalComparator(a, b);
381+
}
382+
375383
// The slotting algorithm works by trying to position the room in the most relevant
376384
// category of the list (red > grey > etc). To accomplish this, we need to consider
377385
// a couple cases: the category existing in the list but having other rooms in it and
@@ -449,7 +457,7 @@ class RoomListStore extends Store {
449457
// based on most recent timestamp.
450458
const changedBoundary = entryCategoryIndex > targetCategoryIndex;
451459
const currentCategory = entryCategoryIndex === targetCategoryIndex;
452-
if (changedBoundary || (currentCategory && lastTimestampFn(room) >= lastTimestampFn(entry.room))) {
460+
if (changedBoundary || (currentCategory && categoryComparator({room}, entry) <= 0)) {
453461
if (changedBoundary) {
454462
// If we changed a boundary, then we've gone too far - go to the top of the last
455463
// section instead.
@@ -479,12 +487,6 @@ class RoomListStore extends Store {
479487
_setRoomCategory(room, category) {
480488
if (!room) return; // This should only happen in tests
481489

482-
if (!this._state.orderImportantFirst) {
483-
// XXX bail here early to avoid https://github.com/vector-im/riot-web/issues/9216
484-
// this may mean that category updates are missed whilst not ordering by importance first
485-
return;
486-
}
487-
488490
const listsClone = {};
489491

490492
// Micro optimization: Support lazily loading the last timestamp in a room

0 commit comments

Comments
 (0)