Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
Detect cycles when looking for predecessor rooms
  • Loading branch information
dbkr authored Aug 20, 2024
2 parents 1ae0c2f + e0ef467 commit a0efed8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5587,10 +5587,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

private findPredecessorRooms(room: Room, verifyLinks: boolean, msc3946ProcessDynamicPredecessor: boolean): Room[] {
const ret: Room[] = [];
const seenRoomIDs = new Set<string>([room.roomId]);

// Work backwards from newer to older rooms
let predecessorRoomId = room.findPredecessor(msc3946ProcessDynamicPredecessor)?.roomId;
while (predecessorRoomId !== null) {
if (predecessorRoomId) {
if (seenRoomIDs.has(predecessorRoomId)) break;
seenRoomIDs.add(predecessorRoomId);
}
const predecessorRoom = this.getRoom(predecessorRoomId);
if (predecessorRoom === null) {
break;
Expand Down

0 comments on commit a0efed8

Please sign in to comment.