Ads screen layout by real width + Qualified Start positions on Credits (wallet switch fix)

Ads: the campaign table squeezed its empty-state note (and the first column) to a
word or a letter per line beside the side cards. Container queries now stack the
side cards under the table and turn rows into cards when the table cannot hold
seven columns, whatever the rail state. cr.css: an empty-state row (one muted
note) spans every column on every Control Room table.

Wallet: Disconnect really lets go (keeps wagmi's disconnected marker, revokes the
injected permission, next connect opens the account picker), so MetaMask no longer
snaps back to the first account. Credits gains Switch account, Disconnect, Add a
position wallet and a Buy from picker (ported from the classic Buy pane), so a
member can add wallets #2..#5 and buy from each while staying signed in as
themselves. Classic dashboard and Wallet screen copy point to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-18 05:15:15 -05:00
parent f875d94d51
commit 44d40863db
16 changed files with 135 additions and 43 deletions
+29 -8
View File
@@ -113,13 +113,19 @@ window.IAPWallet = (function () {
try {
await inj.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] });
const accs = await inj.request({ method: 'eth_accounts' });
if (accs && accs[0]) { provider = inj; await ensureChain(c).catch(() => {}); return accs[0]; }
if (accs && accs[0]) { provider = inj; clearPick(); await ensureChain(c).catch(() => {}); return accs[0]; }
} catch (e) {
if (e && (e.code === 4001 || /reject|denied/i.test(String(e.message || '')))) throw new Error('You closed the account picker. Pick the account you want and try again.');
// closed the picker right after a Disconnect: they may want a different wallet app, so offer the full wallet list
if (e && (e.code === 4001 || /reject|denied/i.test(String(e.message || ''))) && !pickPending()) throw new Error('You closed the account picker. Pick the account you want and try again.');
}
}
return freshConnect(c);
const a = await freshConnect(c, 'Pick the wallet to connect…'); clearPick(); return a;
}
// After Disconnect the next connect is a fresh choice (testers 2026-10-18: Disconnect, then the site snapped straight
// back to the first MetaMask account, so a second wallet could never buy). The flag survives the reload some screens do.
const PICK_KEY = 'ls.wallet.pick';
const pickPending = () => { try { return localStorage.getItem(PICK_KEY) === '1'; } catch (e) { return false; } };
function clearPick() { try { localStorage.removeItem(PICK_KEY); } catch (e) {} }
// A WalletConnect session can die underneath AppKit's cached "connected"
// state: the wallet app rejects or kills it (Trust does this after its own
@@ -128,9 +134,9 @@ window.IAPWallet = (function () {
// Detect that, wipe the stale session, and re-open the picker for a fresh one.
const DEAD_RE = /disconnect|not connected|no matching key|session (topic|expired|deleted|not found)|call connect|please call connect|missing or invalid|relay/i;
const isDead = e => DEAD_RE.test(String((e && e.message) || e || ''));
async function freshConnect(c) {
try { IAP.status('Your wallet session dropped. Reconnect in the picker…'); } catch (e) {}
await disconnect();
async function freshConnect(c, msg) {
try { IAP.status(msg || 'Your wallet session dropped. Reconnect in the picker…'); } catch (e) {}
await dropSession();
try { await modal.open(); } catch (e) {}
const addr = await waitForConnection(180000);
try { if (modal && modal.close) await modal.close(); } catch (e) {}
@@ -142,6 +148,9 @@ window.IAPWallet = (function () {
async function connect() {
const c = await IAP.getConfig();
await initAppKit(c);
if (pickPending()) return pickAccount(); // the member pressed Disconnect: open the account picker, never the old session
// an injected account chosen through pickAccount() is driven directly; AppKit may still hold (or lack) another one
if (provider && provider === window.ethereum) { try { const a = await provider.request({ method: 'eth_accounts' }); if (a && a[0]) return a[0]; } catch (e) {} }
let addr = currentAddress();
if (!addr) {
// give AppKit a moment to rehydrate an existing session before popping the
@@ -269,12 +278,24 @@ window.IAPWallet = (function () {
return { hash, receipt: await waitTx(hash) };
}
async function disconnect() {
// end the wallet session (a dead WalletConnect session, or the first half of a user Disconnect)
async function dropSession() {
// AppKit's disconnect can hang on the WalletConnect relay (esp. mobile) —
// never block on it, so the UI can't get stuck "disconnecting".
try { if (modal && modal.disconnect) await Promise.race([modal.disconnect(), new Promise(r => setTimeout(r, 1200))]); } catch (e) {}
provider = null;
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|wagmi|appkit/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
// keep wagmi/AppKit's own "user disconnected" markers: wiping them made the next page load auto-reconnect the
// injected wallet (MetaMask still trusts the site), the snap-back testers hit on 2026-10-18
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|wagmi|appkit/i.test(k) && !/disconnected|connection_status/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
}
// the member's Disconnect: let go for real, so the next connect can be a different account or wallet.
// MetaMask keeps the site's permission across a plain disconnect; wallet_revokePermissions drops it
// (wallets without it just ignore the call), and the pick flag makes the next connect open the picker.
async function disconnect() {
try { localStorage.setItem(PICK_KEY, '1'); } catch (e) {}
const inj = window.ethereum;
if (inj && inj.request) { try { await Promise.race([inj.request({ method: 'wallet_revokePermissions', params: [{ eth_accounts: {} }] }), new Promise(r => setTimeout(r, 1000))]); } catch (e) {} }
await dropSession();
}
// native balance of the connected wallet (pre-flight check before a buy)