This commit is contained in:
Ryan Barlow
2026-05-26 18:33:27 +01:00
parent 1e14b88d4e
commit fea01e63e9
2 changed files with 34 additions and 13 deletions
+23 -13
View File
@@ -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<void>((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<void> => {
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<void>((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();
+11
View File
@@ -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(