Fix muti game joining issue (#3675)

If this PR fixes an issue, link it below. If not, delete these two
lines.
Resolves #3669 

## Description:

Added a check to make sure that there is only one active lobbyHandle by
checking if there has been a new event before it finished processing.

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

babyboucher
This commit is contained in:
babyboucher
2026-04-14 21:37:22 -05:00
committed by GitHub
parent 35a64fa0d9
commit e569c05fb1
+11 -1
View File
@@ -246,6 +246,7 @@ class Client {
private storeModal: StoreModal;
private tokenLoginModal: TokenLoginModal;
private matchmakingModal: MatchmakingModal;
private mostRecentJoinEvent: number;
private turnstileTokenPromise: Promise<{
token: string;
@@ -739,6 +740,7 @@ class Client {
private async handleJoinLobby(event: CustomEvent<JoinLobbyEvent>) {
const lobby = event.detail;
this.mostRecentJoinEvent = event.timeStamp;
if (this.usernameInput && !this.usernameInput.validateOrShowError()) {
return;
}
@@ -757,7 +759,7 @@ class Client {
if (lobby.source !== "public") {
this.updateJoinUrlForShare(lobby.gameID, config);
}
this.lobbyHandle = joinLobby(this.eventBus, {
const newLobbyHandle = joinLobby(this.eventBus, {
gameID: lobby.gameID,
serverConfig: config,
cosmetics: await getPlayerCosmeticsRefs(),
@@ -768,6 +770,14 @@ class Client {
gameRecord: lobby.gameRecord,
});
if (this.mostRecentJoinEvent !== event.timeStamp) {
newLobbyHandle.stop(true);
console.warn("Join requested, but was superseded");
return;
}
this.lobbyHandle = newLobbyHandle;
this.lobbyHandle.prestart.then(() => {
console.log("Closing modals");
document.getElementById("settings-button")?.classList.add("hidden");