Disconnect wallet: clear all WC state + reload so the picker truly reappears
Clearing localStorage alone wasn't enough — WalletConnect keeps the last wallet and session in memory, so it auto-reconnected the same wallet. Broadened the storage purge and reload the page after disconnect, guaranteeing a clean pick. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -1427,8 +1427,10 @@
|
|||||||
}));
|
}));
|
||||||
if ($('wcDisconnect')) $('wcDisconnect').addEventListener('click', busy($('wcDisconnect'), async () => {
|
if ($('wcDisconnect')) $('wcDisconnect').addEventListener('click', busy($('wcDisconnect'), async () => {
|
||||||
try { await IAPWallet.disconnect(); } catch (e) {}
|
try { await IAPWallet.disconnect(); } catch (e) {}
|
||||||
$('wcDisconnectInfo').textContent = 'Disconnected. Tap Connect or Get test POL to pick a wallet again.';
|
$('wcDisconnectInfo').textContent = 'Disconnected. Reloading so you can pick a different wallet…';
|
||||||
IAP.status('Wallet disconnected. You can connect a different wallet now.', 'ok');
|
IAP.status('Wallet disconnected. Reloading…', 'ok');
|
||||||
|
// reload to drop any in-memory WalletConnect state so the picker reappears
|
||||||
|
setTimeout(() => location.reload(), 700);
|
||||||
}));
|
}));
|
||||||
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
|
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
|
||||||
const me = await (await fetch('/api/me')).json();
|
const me = await (await fetch('/api/me')).json();
|
||||||
|
|||||||
@@ -197,7 +197,9 @@ window.IAPWallet = (function () {
|
|||||||
async function disconnect() {
|
async function disconnect() {
|
||||||
try { if (wcProvider && wcProvider.disconnect) await wcProvider.disconnect(); } catch (e) {}
|
try { if (wcProvider && wcProvider.disconnect) await wcProvider.disconnect(); } catch (e) {}
|
||||||
wcProvider = null; CHOSEN = null; wcSdkPromise = null;
|
wcProvider = null; CHOSEN = null; wcSdkPromise = null;
|
||||||
try { Object.keys(localStorage).forEach(k => { if (/^wc@2|walletconnect|w3m|wcm_/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
|
// WalletConnect caches the last-used wallet + session in localStorage; clear
|
||||||
|
// it all so the next connect re-opens the picker instead of auto-reconnecting.
|
||||||
|
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|ethereum_provider/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
|
||||||
}
|
}
|
||||||
return { connect, signIn, buy, activate, waitTx, disconnect };
|
return { connect, signIn, buy, activate, waitTx, disconnect };
|
||||||
})();
|
})();
|
||||||
|
|||||||
+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=20260908g"></script>
|
<script src="/assets/wallet.js?v=20260908h"></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>
|
||||||
|
|||||||
+2
-2
@@ -696,8 +696,8 @@
|
|||||||
</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=20260908g"></script>
|
<script src="/assets/wallet.js?v=20260908h"></script>
|
||||||
<script src="/assets/my.js?v=20260908j"></script>
|
<script src="/assets/my.js?v=20260908k"></script>
|
||||||
<script src="/assets/chat.js?v=20260907l"></script>
|
<script src="/assets/chat.js?v=20260907l"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user