From 00fc34924cffa7f83948f1c2151b050368c46c4e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 9 Jul 2020 11:34:34 -0600 Subject: [PATCH] Fix rooms disappearing that were created by the user Fixes https://github.com/vector-im/riot-web/issues/14388 We were receiving a read receipt before a room object, leading to the algorithm to assume the room is archived (no membership), which was causing later index issues when the room tried to get moved from archived to untagged. To prevent this, we just ignore nonsensical updates. --- src/stores/room-list/algorithms/Algorithm.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/stores/room-list/algorithms/Algorithm.ts b/src/stores/room-list/algorithms/Algorithm.ts index eee8e60b86..f70eb69e91 100644 --- a/src/stores/room-list/algorithms/Algorithm.ts +++ b/src/stores/room-list/algorithms/Algorithm.ts @@ -41,6 +41,17 @@ import { getListAlgorithmInstance } from "./list-ordering"; */ export const LIST_UPDATED_EVENT = "list_updated_event"; +// These are the causes which require a room to be known in order for us to handle them. If +// a cause in this list is raised and we don't know about the room, we don't handle the update. +// +// Note: these typically happen when a new room is coming in, such as the user creating or +// joining the room. For these cases, we need to know about the room prior to handling it otherwise +// we'll make bad assumptions. +const CAUSES_REQUIRING_ROOM = [ + RoomUpdateCause.Timeline, + RoomUpdateCause.ReadReceipt, +]; + interface IStickyRoom { room: Room; position: number; @@ -755,6 +766,11 @@ export class Algorithm extends EventEmitter { } if (!this.roomIdsToTags[room.roomId]) { + if (CAUSES_REQUIRING_ROOM.includes(cause)) { + console.warn(`Skipping tag update for ${room.roomId} because we don't know about the room`); + return false; + } + // TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035 console.log(`[RoomListDebug] Updating tags for room ${room.roomId} (${room.name})`);