From df765eda23e8a2d60c7a4fb33d327a4ab6407557 Mon Sep 17 00:00:00 2001 From: Aotumuri Date: Fri, 15 May 2026 08:52:20 +0800 Subject: [PATCH 1/3] add clan arg --- src/client/ClanModal.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client/ClanModal.ts b/src/client/ClanModal.ts index 975367c2b7..d5c2c468e0 100644 --- a/src/client/ClanModal.ts +++ b/src/client/ClanModal.ts @@ -58,6 +58,7 @@ export class ClanModal extends BaseModal { pendingRequestCount: number; stats: ClanStats | null; } | null = null; + private openGeneration = 0; private get onListView(): boolean { return this.view === "list" && !this.selectedClanTag; @@ -158,7 +159,12 @@ export class ClanModal extends BaseModal { }); } - protected onOpen(): void { + protected onOpen(args?: Record): void { + const clanTag = typeof args?.clan === "string" ? args.clan.trim() : ""; + if (clanTag) { + void this.openInitialView(clanTag); + return; + } this.loadMyClans(); } @@ -170,6 +176,14 @@ export class ClanModal extends BaseModal { this.myRole = null; this.browseCache = null; this.detailCache = null; + this.openGeneration++; + } + + private async openInitialView(clanTag: string) { + const generation = ++this.openGeneration; + await this.loadMyClans(); + if (generation !== this.openGeneration || !this.isModalOpen) return; + this.openDetail(clanTag); } private async loadMyClans() { From 9057f3d9bfc1e81cd70887f6d425556e2c562eff Mon Sep 17 00:00:00 2001 From: Aotumuri Date: Fri, 15 May 2026 08:58:57 +0800 Subject: [PATCH 2/3] fixed --- src/client/ClanModal.ts | 3 +++ src/client/ModalRouter.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/client/ClanModal.ts b/src/client/ClanModal.ts index d5c2c468e0..e4b1b0886f 100644 --- a/src/client/ClanModal.ts +++ b/src/client/ClanModal.ts @@ -16,6 +16,7 @@ import "./components/clan/ClanTransferView"; import "./components/ConfirmDialog"; import "./components/CopyButton"; import { modalHeader } from "./components/ui/ModalHeader"; +import { modalRouter } from "./ModalRouter"; import { translateText } from "./Utils"; type View = @@ -153,6 +154,7 @@ export class ClanModal extends BaseModal { this.selectedClanTag = ""; this.myRole = null; this.detailCache = null; + modalRouter.syncArgs("clan", { clan: null }); }, ariaLabel, rightContent: clan ? this.tagPill(clan.tag) : undefined, @@ -399,6 +401,7 @@ export class ClanModal extends BaseModal { private openDetail(tag: string) { this.selectedClanTag = tag; this.view = "detail"; + modalRouter.syncArgs("clan", { clan: tag }); } private renderMyClans() { diff --git a/src/client/ModalRouter.ts b/src/client/ModalRouter.ts index a2224f86e4..377827db22 100644 --- a/src/client/ModalRouter.ts +++ b/src/client/ModalRouter.ts @@ -123,6 +123,24 @@ class ModalRouter { this.replaceHash("#" + params.toString()); } + /** Called when a router-managed modal changes non-tab route state. */ + syncArgs(name: string, args: Record): void { + if (this.routingFromUrl) return; + if (this.currentName !== name) return; + const params = this.currentHashParams(); + params.set("modal", name); + for (const [key, value] of Object.entries(args)) { + if (key === "modal") continue; + if (value === undefined || value === null || value === "") { + params.delete(key); + continue; + } + if (typeof value === "object") continue; + params.set(key, String(value)); + } + this.replaceHash("#" + params.toString()); + } + /** True if the current hash is `#modal=...`. */ isHashRouted(): boolean { const hash = window.location.hash; From e3738fe74190df8c5f1103027ab3bc3d565bcb43 Mon Sep 17 00:00:00 2001 From: Aotumuri Date: Fri, 15 May 2026 09:07:07 +0800 Subject: [PATCH 3/3] fixed --- src/client/ModalRouter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/ModalRouter.ts b/src/client/ModalRouter.ts index 377827db22..0162240572 100644 --- a/src/client/ModalRouter.ts +++ b/src/client/ModalRouter.ts @@ -160,7 +160,7 @@ class ModalRouter { if (args) { for (const [key, value] of Object.entries(args)) { if (key === "modal") continue; - if (value === undefined || value === null) continue; + if (value === undefined || value === null || value === "") continue; if (typeof value === "object") continue; params.set(key, String(value)); }