Fix room duplication when the sticky room reference changes
This commit is contained in:
parent
34bd59c151
commit
8739e2f781
1 changed files with 6 additions and 2 deletions
|
@ -215,7 +215,10 @@ export class Algorithm extends EventEmitter {
|
||||||
// When we do have the room, re-add the old room (if needed) to the algorithm
|
// When we do have the room, re-add the old room (if needed) to the algorithm
|
||||||
// and remove the sticky room from the algorithm. This is so the underlying
|
// and remove the sticky room from the algorithm. This is so the underlying
|
||||||
// algorithm doesn't try and confuse itself with the sticky room concept.
|
// algorithm doesn't try and confuse itself with the sticky room concept.
|
||||||
if (lastStickyRoom) {
|
// We don't add the new room if the sticky room isn't changing because that's
|
||||||
|
// an easy way to cause duplication. We have to do room ID checks instead of
|
||||||
|
// referential checks as the references can differ through the lifecycle.
|
||||||
|
if (lastStickyRoom && lastStickyRoom.room && lastStickyRoom.room.roomId !== val.roomId) {
|
||||||
// Lie to the algorithm and re-add the room to the algorithm
|
// Lie to the algorithm and re-add the room to the algorithm
|
||||||
await this.handleRoomUpdate(lastStickyRoom.room, RoomUpdateCause.NewRoom);
|
await this.handleRoomUpdate(lastStickyRoom.room, RoomUpdateCause.NewRoom);
|
||||||
}
|
}
|
||||||
|
@ -643,7 +646,8 @@ export class Algorithm extends EventEmitter {
|
||||||
console.log(`Handle room update for ${room.roomId} called with cause ${cause}`);
|
console.log(`Handle room update for ${room.roomId} called with cause ${cause}`);
|
||||||
if (!this.algorithms) throw new Error("Not ready: no algorithms to determine tags from");
|
if (!this.algorithms) throw new Error("Not ready: no algorithms to determine tags from");
|
||||||
|
|
||||||
const isSticky = this._stickyRoom && this._stickyRoom.room === room;
|
// Note: check the isSticky against the room ID just in case the reference is wrong
|
||||||
|
const isSticky = this._stickyRoom && this._stickyRoom.room && this._stickyRoom.room.roomId === room.roomId;
|
||||||
if (cause === RoomUpdateCause.NewRoom) {
|
if (cause === RoomUpdateCause.NewRoom) {
|
||||||
const isForLastSticky = this._lastStickyRoom && this._lastStickyRoom.room === room;
|
const isForLastSticky = this._lastStickyRoom && this._lastStickyRoom.room === room;
|
||||||
const roomTags = this.roomIdsToTags[room.roomId];
|
const roomTags = this.roomIdsToTags[room.roomId];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue