From 0332bc99cbc1741114602250111d1f940026df34 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 13 Oct 2021 14:39:09 +0100 Subject: [PATCH 1/2] Fix bug where room list would get stuck showing no rooms If you had an unsent message in a room that was in a sublist with the 'Show rooms with unread messages first' option enabled, the room list would show no rooms next time you restarted element and get stuck that way. This was because there was a different notification category for rooms with unsent messages but the algorithm is hard-coded to add only a fixed set of categories to its list, and it missed 'unsent', so it NPEed when it encountered a room with an unsent message. This just adds the category (assuming that we want to show rooms with unsent messages first). It doesn't make it less hard-coded, or fix the fact that an exception in the room list code causes everything to break. Fixes https://github.com/vector-im/element-web/issues/19373 --- .../algorithms/list-ordering/ImportanceAlgorithm.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts index 1d35df331d..14dfec8fa2 100644 --- a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts +++ b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts @@ -37,6 +37,7 @@ interface ICategoryIndex { // comments! Check the usage of Category carefully to figure out what needs changing // if you're going to change this array's order. const CATEGORY_ORDER = [ + NotificationColor.Unsent, NotificationColor.Red, NotificationColor.Grey, NotificationColor.Bold, @@ -50,9 +51,10 @@ const CATEGORY_ORDER = [ * interfere with this algorithm, however manual ordering does. * * The importance of a room is defined by the kind of notifications, if any, are - * present on the room. These are classified internally as Red, Grey, Bold, and - * Idle. Red rooms have mentions, grey have unread messages, bold is a less noisy - * version of grey, and idle means all activity has been seen by the user. + * present on the room. These are classified internally as Unsent, Red, Grey, + * Bold, and Idle. 'Unsent' rooms habe unsent messages, Red rooms have mentions, + * grey have unread messages, bold is a less noisy version of grey, and idle + * means all activity has been seen by the user. * * The algorithm works by monitoring all room changes, including new messages in * tracked rooms, to determine if it needs a new category or different placement @@ -74,6 +76,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { // noinspection JSMethodCanBeStatic private categorizeRooms(rooms: Room[]): ICategorizedRoomMap { const map: ICategorizedRoomMap = { + [NotificationColor.Unsent]: [], [NotificationColor.Red]: [], [NotificationColor.Grey]: [], [NotificationColor.Bold]: [], From c2ed27a1b2c41707721d2aa0430a2f25e83c9313 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 13 Oct 2021 15:42:57 +0100 Subject: [PATCH 2/2] Typo --- .../room-list/algorithms/list-ordering/ImportanceAlgorithm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts index 14dfec8fa2..3cc393305e 100644 --- a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts +++ b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts @@ -52,7 +52,7 @@ const CATEGORY_ORDER = [ * * The importance of a room is defined by the kind of notifications, if any, are * present on the room. These are classified internally as Unsent, Red, Grey, - * Bold, and Idle. 'Unsent' rooms habe unsent messages, Red rooms have mentions, + * Bold, and Idle. 'Unsent' rooms have unsent messages, Red rooms have mentions, * grey have unread messages, bold is a less noisy version of grey, and idle * means all activity has been seen by the user. *