From 4d427f8b863c0bd03a7add9ed198d738cc6d14d3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 22:33:04 -0700 Subject: Actually assign the default payment address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The auto-claim ran once at feature init — before Ark finishes connecting — saw an unavailable wallet and gave up for good, so users got a claim box instead of their npub address. It now retries while Ark comes up (and after a failed claim), and shows a setting-up state rather than the claim form while it works. Co-Authored-By: Claude Fable 5 --- src/features/names.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/features') diff --git a/src/features/names.js b/src/features/names.js index 33bddd7..77b2554 100644 --- a/src/features/names.js +++ b/src/features/names.js @@ -83,9 +83,17 @@ export function namesFeature(ctx) { // prefix of the wallet's npub — unique, boring, and free. Custom names are // an optional change (and may cost something one day, to keep squatters // out), so nothing here ever blocks the wallet. - async function refresh() { + let retryTimer = null; + async function refresh(attempt = 0) { + clearTimeout(retryTimer); try { - if (!available()) { checked = true; render(); return; } + if (!available()) { + // Ark connects lazily AFTER the wallet opens, so the first pass + // usually lands too early. Keep looking for a while rather than + // giving up and leaving the user staring at a claim box. + if (attempt < 40) { retryTimer = setTimeout(() => refresh(attempt + 1), 3000); return; } + checked = true; render(); return; + } let st = load(); if (!st.name) { await lookupMine(); st = load(); } if (!st.name) { @@ -107,7 +115,12 @@ export function namesFeature(ctx) { if (!st.name) return; const uri = await currentUri(); if (uri && uri !== st.uri) await claim(st.name); - } catch (e) { checked = true; console.warn('names: refresh failed', e.message); } + } catch (e) { + console.warn('names: refresh failed', e.message); + if (attempt < 10) { retryTimer = setTimeout(() => refresh(attempt + 1), 5000); return; } + checked = true; + render(); + } } // ---- sending to a name ------------------------------------------------- @@ -220,6 +233,11 @@ export function namesFeature(ctx) { // The Receive tab's default pane: your name, big and scannable. function namePane(seg) { const st = load(); + if (!st.name && !checked) { + return h('div', { class: 'card col', style: 'align-items:center;gap:10px' }, + seg, h('span', { class: 'spinner' }), + h('div', { class: 'small muted' }, t('namesSettingUp'))); + } if (!st.name) { return h('div', { class: 'card col', style: 'gap:10px' }, seg, @@ -237,6 +255,7 @@ export function namesFeature(ctx) { return { id: 'names', init() { checked = false; refresh(); }, + stop() { clearTimeout(retryTimer); }, receiveModes() { if (!available()) return []; return [{ -- cgit v1.2.3