@@ -45,6 +45,7 @@ import {
4545 SendKickPlayerIntentEvent ,
4646 SendUpdateGameConfigIntentEvent ,
4747} from "./Transport" ;
48+ import { TurnstileManager } from "./TurnstileManager" ;
4849import { UserSettingModal } from "./UserSettingModal" ;
4950import "./UsernameInput" ;
5051import { UsernameInput } from "./UsernameInput" ;
@@ -54,7 +55,6 @@ import {
5455 isInIframe ,
5556 translateText ,
5657} from "./Utils" ;
57- import { TurnstileManager } from "./TurnstileManager" ;
5858import "./components/DesktopNavBar" ;
5959import "./components/Footer" ;
6060import "./components/MainLayout" ;
@@ -234,6 +234,7 @@ class Client {
234234 private matchmakingModal : MatchmakingModal ;
235235
236236 private gutterAds : GutterAds ;
237+ private isJoiningLobby = false ;
237238
238239 private turnstileManager : TurnstileManager ;
239240 private serverConfigPrefetch : Promise <
@@ -697,6 +698,9 @@ class Client {
697698 }
698699
699700 private handleUrl ( ) {
701+ if ( this . isJoiningLobby ) {
702+ return ;
703+ }
700704 // Check if CrazyGames SDK is enabled first (no hash needed in CrazyGames)
701705 if ( crazyGamesSDK . isOnCrazyGames ( ) ) {
702706 const lobbyId = crazyGamesSDK . getInviteGameId ( ) ;
@@ -802,13 +806,15 @@ class Client {
802806 private async handleJoinLobby ( event : CustomEvent < JoinLobbyEvent > ) {
803807 const lobby = event . detail ;
804808 const joinAttemptId = ++ this . joinAttemptId ;
809+ this . isJoiningLobby = true ;
805810 console . log ( `joining lobby ${ lobby . gameID } ` ) ;
806811 if ( this . gameStop !== null ) {
807812 console . log ( "joining lobby, stopping existing game" ) ;
808813 this . gameStop ( true ) ;
809814 document . body . classList . remove ( "in-game" ) ;
810815 }
811816 if ( lobby . source === "public" ) {
817+ this . joinModal ?. close ( ) ;
812818 this . joinPublicModal ?. open ( lobby . gameID , lobby . publicLobbyInfo ) ;
813819 }
814820 const configPromise = this . getServerConfigPrefetched ( ) ;
@@ -907,6 +913,7 @@ class Client {
907913 this . gutterAds . hide ( ) ;
908914 } ,
909915 ( ) => {
916+ this . isJoiningLobby = false ;
910917 this . joinModal . close ( ) ;
911918 this . joinPublicModal ?. closeWithoutLeaving ( ) ;
912919 this . publicLobby . stop ( ) ;
@@ -950,6 +957,7 @@ class Client {
950957
951958 private async handleLeaveLobby ( /* event: CustomEvent */ ) {
952959 this . joinAttemptId ++ ;
960+ this . isJoiningLobby = false ;
953961 if ( this . gameStop === null ) {
954962 try {
955963 history . replaceState ( null , "" , "/" ) ;
0 commit comments