Skip to content

Commit da2fd35

Browse files
committed
Add sanity check to ensure we don't accidentally proliferate rooms
This small check just ensures that we aren't about to blindly accept that the calling code knows what it is doing. There are some unknown cases where NewRoom gets fired for rooms we already know about, so in those cases we just change it to a PossibleTagChange which is what the caller likely intended. Many of the edge cases are unknown, though this can happen for an invite being accepted (for example). It's easier to handle it here instead of tracking down every single possibility and fixing it higher up.
1 parent 6a191ea commit da2fd35

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/stores/room-list/algorithms/Algorithm.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ export class Algorithm extends EventEmitter {
587587
public async handleRoomUpdate(room: Room, cause: RoomUpdateCause): Promise<boolean> {
588588
if (!this.algorithms) throw new Error("Not ready: no algorithms to determine tags from");
589589

590+
if (cause === RoomUpdateCause.NewRoom) {
591+
const roomTags = this.roomIdsToTags[room.roomId];
592+
if (roomTags && roomTags.length > 0) {
593+
console.warn(`${room.roomId} is reportedly new but is already known - assuming TagChange instead`);
594+
cause = RoomUpdateCause.PossibleTagChange;
595+
}
596+
}
597+
590598
if (cause === RoomUpdateCause.PossibleTagChange) {
591599
// TODO: Be smarter and splice rather than regen the planet. https://github.com/vector-im/riot-web/issues/14035
592600
// TODO: No-op if no change. https://github.com/vector-im/riot-web/issues/14035

0 commit comments

Comments
 (0)