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

Ensure the room list always triggers updates on itself #4175

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/stores/RoomListStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ class RoomListStore extends Store {
_slotRoomIntoList(room, category, tag, existingEntries, newList, lastTimestampFn) {
const targetCategoryIndex = CATEGORY_ORDER.indexOf(category);

let categoryComparator = (a, b) => lastTimestampFn(a.room) >= lastTimestampFn(b.room);
const sortAlgorithm = getListAlgorithm(tag, this._state.algorithm);
if (sortAlgorithm === ALGO_RECENT) {
categoryComparator = (a, b) => this._recentsComparator(a, b, lastTimestampFn);
} else if (sortAlgorithm === ALGO_ALPHABETIC) {
categoryComparator = (a, b) => this._lexicographicalComparator(a, b);
}

// The slotting algorithm works by trying to position the room in the most relevant
// category of the list (red > grey > etc). To accomplish this, we need to consider
// a couple cases: the category existing in the list but having other rooms in it and
Expand Down Expand Up @@ -449,7 +457,7 @@ class RoomListStore extends Store {
// based on most recent timestamp.
const changedBoundary = entryCategoryIndex > targetCategoryIndex;
const currentCategory = entryCategoryIndex === targetCategoryIndex;
if (changedBoundary || (currentCategory && lastTimestampFn(room) >= lastTimestampFn(entry.room))) {
if (changedBoundary || (currentCategory && categoryComparator({room}, entry) <= 0)) {
if (changedBoundary) {
// If we changed a boundary, then we've gone too far - go to the top of the last
// section instead.
Expand Down Expand Up @@ -479,12 +487,6 @@ class RoomListStore extends Store {
_setRoomCategory(room, category) {
if (!room) return; // This should only happen in tests

if (!this._state.orderImportantFirst) {
// XXX bail here early to avoid https://github.com/vector-im/riot-web/issues/9216
// this may mean that category updates are missed whilst not ordering by importance first
return;
}

const listsClone = {};

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