From 2cc21457bd7976a59042057348e024925e67a1bd Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 8 Sep 2026 11:41:07 -0500 Subject: [PATCH] Don't leave the connect modal stuck when already connected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On click, AppKit's session hasn't always rehydrated yet, so currentAddress() returned null and we popped the picker even for an already-connected wallet — and nothing closed it, leaving it stuck on screen after a purchase. Wait briefly for the existing session to rehydrate before opening the picker, and always close the modal once we have an address. Co-Authored-By: Claude Opus 4.8 --- public/assets/wallet.js | 6 ++++++ public/index.html | 2 +- public/my.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/assets/wallet.js b/public/assets/wallet.js index 9b06470..257120c 100644 --- a/public/assets/wallet.js +++ b/public/assets/wallet.js @@ -80,7 +80,13 @@ window.IAPWallet = (function () { const c = await IAP.getConfig(); await initAppKit(c); let addr = currentAddress(); + if (!addr) { + // give AppKit a moment to rehydrate an existing session before popping the + // picker — otherwise an already-connected wallet still gets the modal + for (let i = 0; i < 8 && !addr; i++) { await new Promise(r => setTimeout(r, 150)); addr = currentAddress(); } + } if (!addr) { try { await modal.open(); } catch (e) {} addr = await waitForConnection(180000); } + try { if (modal && modal.close) await modal.close(); } catch (e) {} // dismiss the picker once we're connected provider = await resolveProvider(); await ensureChain(c).catch(() => {}); // AppKit already connects on the right network; switch is best-effort return addr; diff --git a/public/index.html b/public/index.html index a90e407..09d2cd7 100644 --- a/public/index.html +++ b/public/index.html @@ -439,7 +439,7 @@ - + diff --git a/public/my.html b/public/my.html index 4b53363..e2997a8 100644 --- a/public/my.html +++ b/public/my.html @@ -695,7 +695,7 @@ - +