From fea01e63e95b93e49f9f7360a44aa754d5c5b6ed Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Tue, 26 May 2026 18:33:27 +0100 Subject: [PATCH] rabbit --- src/client/ClanTagInput.ts | 36 +++++++++++++++++++++------------ src/client/SinglePlayerModal.ts | 11 ++++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/client/ClanTagInput.ts b/src/client/ClanTagInput.ts index 98dc33e1b..2c2a92e91 100644 --- a/src/client/ClanTagInput.ts +++ b/src/client/ClanTagInput.ts @@ -150,20 +150,30 @@ export class ClanTagInput extends LitElement { this.ownershipError = ""; localStorage.setItem(clanTagKey, ""); this.currentCheck = Promise.resolve(); - } else if (options.immediate) { - // Initial mount / non-typing trigger — no input to coalesce, run now. - this.currentCheck = this.checkOwnership(tag); } else { - const debounce = new Promise((resolve) => { - this.resolveDebounce = resolve; - }); - this.checkTimer = setTimeout(() => { - this.checkTimer = null; - const resolve = this.resolveDebounce; - this.resolveDebounce = null; - resolve?.(); - }, CLAN_OWNERSHIP_DEBOUNCE_MS); - this.currentCheck = debounce.then(() => this.checkOwnership(tag)); + // Snapshot the generation so cancelled debounce chains skip the API + // round-trip entirely — checkOwnership's internal stillCurrent() only + // fires after getUserMe() has already returned. + const generation = this.checkCounter; + const run = (): Promise => { + if (generation !== this.checkCounter) return Promise.resolve(); + return this.checkOwnership(tag); + }; + if (options.immediate) { + // Initial mount / non-typing trigger — no input to coalesce, run now. + this.currentCheck = run(); + } else { + const debounce = new Promise((resolve) => { + this.resolveDebounce = resolve; + }); + this.checkTimer = setTimeout(() => { + this.checkTimer = null; + const resolve = this.resolveDebounce; + this.resolveDebounce = null; + resolve?.(); + }, CLAN_OWNERSHIP_DEBOUNCE_MS); + this.currentCheck = debounce.then(run); + } } this.refreshError(); diff --git a/src/client/SinglePlayerModal.ts b/src/client/SinglePlayerModal.ts index d2d2f2291..1fb1b9655 100644 --- a/src/client/SinglePlayerModal.ts +++ b/src/client/SinglePlayerModal.ts @@ -651,6 +651,17 @@ export class SinglePlayerModal extends BaseModal { "clan-tag-input", ) as ClanTagInput | null; + // Validate identity before dispatching/closing so a failed clan-tag + // ownership check keeps the modal open with the user's configured game + // settings intact rather than silently dropping them. + if (clanTagInput) { + await clanTagInput.awaitValidation(); + if (!clanTagInput.validateOrShowError()) return; + } + if (usernameInput && !usernameInput.validateOrShowError()) { + return; + } + await crazyGamesSDK.requestMidgameAd(); this.dispatchEvent(