Don't leave the connect modal stuck when already connected
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 <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,13 @@ window.IAPWallet = (function () {
|
|||||||
const c = await IAP.getConfig();
|
const c = await IAP.getConfig();
|
||||||
await initAppKit(c);
|
await initAppKit(c);
|
||||||
let addr = currentAddress();
|
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); }
|
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();
|
provider = await resolveProvider();
|
||||||
await ensureChain(c).catch(() => {}); // AppKit already connects on the right network; switch is best-effort
|
await ensureChain(c).catch(() => {}); // AppKit already connects on the right network; switch is best-effort
|
||||||
return addr;
|
return addr;
|
||||||
|
|||||||
+1
-1
@@ -439,7 +439,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script src="/assets/common.js?v=20260908c"></script>
|
<script src="/assets/common.js?v=20260908c"></script>
|
||||||
<script src="/assets/wallet.js?v=20260908n"></script>
|
<script src="/assets/wallet.js?v=20260908q"></script>
|
||||||
<script src="/assets/home.js?v=20260906m"></script>
|
<script src="/assets/home.js?v=20260906m"></script>
|
||||||
<script src="/assets/chat.js?v=20260906m"></script>
|
<script src="/assets/chat.js?v=20260906m"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+1
-1
@@ -695,7 +695,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20260908c"></script>
|
<script src="/assets/common.js?v=20260908c"></script>
|
||||||
<script src="/assets/wallet.js?v=20260908n"></script>
|
<script src="/assets/wallet.js?v=20260908q"></script>
|
||||||
<script src="/assets/my.js?v=20260908l"></script>
|
<script src="/assets/my.js?v=20260908l"></script>
|
||||||
<script src="/assets/chat.js?v=20260907l"></script>
|
<script src="/assets/chat.js?v=20260907l"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user