diff --git a/js/profile-menu.js b/js/profile-menu.js index 339ada6..ca252c1 100644 --- a/js/profile-menu.js +++ b/js/profile-menu.js @@ -162,17 +162,25 @@ } if (["new", "import", "wc", "unlock"].includes(action)) { close(); - const savedLabel = btn.querySelector(".wallet-label")?.textContent; - const walletLabel = btn.querySelector(".wallet-label"); - if (walletLabel) walletLabel.textContent = "loading…"; - const ready = await ensureFlow(); - if (walletLabel && savedLabel) walletLabel.textContent = savedLabel; - if (ready) { - window.siriusSignInWallet(action); - } else { - // Fallback: navigate to portal.html?mode=X if the module can't load. - location.href = PORTAL_URL + "?mode=" + action; + // Always route to the portal — it renders the tabbed sign-in INLINE + // as page content (?mode=X picks the starting tab). Prevents the + // "modal opens on top of the page" symptom the launcher used to have. + // Only stay on-page if we're already on portal.html. + const onPortal = /\/portal\.html(?:$|[?#])/.test(location.pathname + location.search); + if (onPortal && typeof window.siriusRenderSignInInline === "function") { + const hasSaved = (() => { try { return !!localStorage.getItem("bns.wallet.v1"); } catch { return false; } })(); + const mode = (action === "unlock" && !hasSaved) ? "import" : action; + const mount = document.getElementById("signin-inline"); + if (mount) { + window.siriusRenderSignInInline(mount, mode); + document.getElementById("signin")?.scrollIntoView({ behavior: "smooth", block: "start" }); + return; + } } + // Not on portal (or the inline mount is missing) — take the user + // there. portal.html?mode=X renders the tabbed sign-in as its main + // content, no modal. + location.href = PORTAL_URL + "?mode=" + action; } });