@@ -372,6 +372,14 @@ class RoomListStore extends Store {
372
372
_slotRoomIntoList ( room , category , tag , existingEntries , newList , lastTimestampFn ) {
373
373
const targetCategoryIndex = CATEGORY_ORDER . indexOf ( category ) ;
374
374
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
+
375
383
// The slotting algorithm works by trying to position the room in the most relevant
376
384
// category of the list (red > grey > etc). To accomplish this, we need to consider
377
385
// a couple cases: the category existing in the list but having other rooms in it and
@@ -449,7 +457,7 @@ class RoomListStore extends Store {
449
457
// based on most recent timestamp.
450
458
const changedBoundary = entryCategoryIndex > targetCategoryIndex ;
451
459
const currentCategory = entryCategoryIndex === targetCategoryIndex ;
452
- if ( changedBoundary || ( currentCategory && lastTimestampFn ( room ) >= lastTimestampFn ( entry . room ) ) ) {
460
+ if ( changedBoundary || ( currentCategory && categoryComparator ( { room} , entry ) <= 0 ) ) {
453
461
if ( changedBoundary ) {
454
462
// If we changed a boundary, then we've gone too far - go to the top of the last
455
463
// section instead.
@@ -479,12 +487,6 @@ class RoomListStore extends Store {
479
487
_setRoomCategory ( room , category ) {
480
488
if ( ! room ) return ; // This should only happen in tests
481
489
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
-
488
490
const listsClone = { } ;
489
491
490
492
// Micro optimization: Support lazily loading the last timestamp in a room
0 commit comments