Skip to content

Commit

Permalink
fix(Lobby): Clean the room on destroy.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Nov 28, 2023
1 parent b3ae520 commit 7841a38
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/xmpp/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ export default class Lobby {
this.lobbyRoom.addEventListener(
XMPPEvents.MUC_DESTROYED,
(reason, jid) => {
this.lobbyRoom?.clean();

this.lobbyRoom = undefined;
logger.info('Lobby room left(destroyed)!');

// we are receiving the jid of the main room
// means we are invited to join, maybe lobby was disabled
if (jid) {
Expand All @@ -317,8 +322,6 @@ export default class Lobby {
return;
}

this.lobbyRoom.clean();

this.mainRoom.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
});

Expand All @@ -327,7 +330,9 @@ export default class Lobby {
this.mainRoom.addEventListener(
XMPPEvents.MUC_JOINED,
() => {
this.leave();
this.leave().catch(() => {
// this may happen if the room has been destroyed.
});
});
}

Expand Down

0 comments on commit 7841a38

Please sign in to comment.