From c8fc3298f85b416163032afc7a959b99a20569f2 Mon Sep 17 00:00:00 2001
From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com>
Date: Tue, 26 May 2026 18:59:53 +0100
Subject: [PATCH] other modals too
---
src/client/JoinLobbyModal.ts | 12 +++++++++++-
src/client/Matchmaking.ts | 14 ++++++++++++--
src/client/components/RankedModal.ts | 10 +++++++++-
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/client/JoinLobbyModal.ts b/src/client/JoinLobbyModal.ts
index 115bff0fa..b36cbf7c1 100644
--- a/src/client/JoinLobbyModal.ts
+++ b/src/client/JoinLobbyModal.ts
@@ -37,6 +37,7 @@ import "./components/CopyButton";
import "./components/LobbyConfigItem";
import "./components/LobbyPlayerView";
import { modalHeader } from "./components/ui/ModalHeader";
+import { IdentityReadyController } from "./identity/IdentityReadyController";
import { nationsConfigToSlider } from "./utilities/GameConfigHelpers";
@customElement("join-lobby-modal")
@@ -58,6 +59,7 @@ export class JoinLobbyModal extends BaseModal {
private leaveLobbyOnClose = true;
private countdownTimerId: number | null = null;
+ private identity = new IdentityReadyController(this);
private handledJoinTimeout = false;
private isPrivateLobby(): boolean {
@@ -250,9 +252,14 @@ export class JoinLobbyModal extends BaseModal {
>
@@ -891,6 +898,9 @@ export class JoinLobbyModal extends BaseModal {
private async joinLobbyFromInput(e: SubmitEvent): Promise {
e.preventDefault();
+ // Guard against Enter-key submit while the identity gate hasn't cleared
+ // (the disabled button blocks click but not keyboard submission).
+ if (!this.identity.ready) return;
const lobbyId = this.normalizeLobbyId(this.lobbyIdInput.value);
if (!lobbyId) {
this.showMessage(translateText("private_lobby.not_found"), "red");
diff --git a/src/client/Matchmaking.ts b/src/client/Matchmaking.ts
index 146a6cf1e..67ccd7b45 100644
--- a/src/client/Matchmaking.ts
+++ b/src/client/Matchmaking.ts
@@ -7,6 +7,7 @@ import { getPlayToken } from "./Auth";
import { BaseModal } from "./components/BaseModal";
import "./components/Difficulties";
import { modalHeader } from "./components/ui/ModalHeader";
+import { IdentityReadyController } from "./identity/IdentityReadyController";
import { JoinLobbyEvent } from "./Main";
import { translateText } from "./Utils";
@@ -204,6 +205,7 @@ export class MatchmakingModal extends BaseModal {
@customElement("matchmaking-button")
export class MatchmakingButton extends LitElement {
@state() private isLoggedIn = false;
+ private identity = new IdentityReadyController(this);
constructor() {
super();
@@ -226,12 +228,20 @@ export class MatchmakingButton extends LitElement {
}
render() {
+ const disabled = this.isLoggedIn && !this.identity.ready;
+ const title = disabled
+ ? this.identity.validating
+ ? translateText("username.tag_checking")
+ : translateText("matchmaking_modal.title")
+ : translateText("matchmaking_modal.title");
return this.isLoggedIn
? html`