diff options
| author | Adam Soltys <[email protected]> | 2026-08-17 23:54:04 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-17 23:54:04 -0700 |
| commit | 9484c2b29a621a4413b91a88391d4f299d3323a2 (patch) | |
| tree | 211e25fa9a03d547212b42cacf716fa2983d3a86 /src | |
| parent | 373566416e6a3ce8ff83aafcd6afc96147a01580 (diff) | |
| download | coinosv3-9484c2b29a621a4413b91a88391d4f299d3323a2.tar.gz coinosv3-9484c2b29a621a4413b91a88391d4f299d3323a2.zip | |
The claim field greets you by name: your nostr username arrives pre-filled when the registrar confirms it's free (or already yours) — editable, never auto-claimed
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JtaatFfAbx91Nh3xqKVqKz
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/names.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/features/names.js b/src/features/names.js index 73e34de..d3971a4 100644 --- a/src/features/names.js +++ b/src/features/names.js @@ -262,7 +262,31 @@ export function namesFeature(ctx) { // ---- UI --------------------------------------------------------------- + // Suggest the identity's own nostr username as the claim default — nobody + // should have to retype who they already are — but only when that name is + // actually free on the registrar (or already theirs to retake). + let suggestedFor = null; + function suggestName() { + const me = (hook('nostrLoginIdentity') || {}).pubkey || (wallet.nostrPubkey && wallet.nostrPubkey()); + if (!me || suggestedFor === me || ui.nameClaim) return; + suggestedFor = me; + (async () => { + try { + const prof = hook('cachedProfile', me); + const cand = String((prof && prof.name) || '').toLowerCase().replace(/[^a-z0-9._-]/g, '').slice(0, 30); + if (!cand || /^npub1/.test(cand)) return; + const r = await withTimeout( + fetch(`${REGISTRAR}/name/${encodeURIComponent(cand)}?domain=${encodeURIComponent(DOMAIN())}`).then((x) => x.json()), + 8000, 'registrar'); + const free = r && r.taken === false; + const mine = r && r.taken && r.pubkey === me; + if ((free || mine) && !ui.nameClaim) { ui.nameClaim = cand; render(); } + } catch {} + })(); + } + function claimForm(big) { + suggestName(); return h('div', { class: 'col', style: 'gap:8px;width:100%' }, ui.nameClaimError ? h('div', { class: 'notice err' }, ui.nameClaimError) : null, h('div', { class: 'row gap6' }, |
