From 0427a1b02c21fd5fa9f5df8a86e435dbb84a8451 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 26 Aug 2026 12:06:00 -0700 Subject: The page arrives light and paints at once: index.html shrinks to 46KB with a static boot shell baked in — brand row, and the profile frame when the path names one — while the 789KB bundle moves to a content-addressed app-.js the browser keeps (a repeat visit re-downloads kilobytes, not the app); the nostr-tools barrel import goes subpath, and the NIP-46 signer client ships as its own lazy file fetched on first bunker login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_019eA8JRq9Wr7z2fRQk99HLi --- src/features/nostrlogin.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/features') diff --git a/src/features/nostrlogin.js b/src/features/nostrlogin.js index 5195778..9c4156f 100644 --- a/src/features/nostrlogin.js +++ b/src/features/nostrlogin.js @@ -162,11 +162,19 @@ export function nostrLoginFeature(ctx) { // from another device); when the app connects, login continues by itself. let nc = null; let ncRun = null; - function startNostrConnect(run) { + let ncToken = null; // guards the async gap while the nip46 module loads + async function startNostrConnect(run) { if (nc) nc.cancel(); ncRun = run; - nc = nostrConnect(); - const mine = nc; + const token = (ncToken = {}); + let mine; + try { mine = await nostrConnect(); } catch { + if (token === ncToken && ui.nostrConnectOpen) { ui.nostrConnectOpen = false; render(); } + return; + } + if (token !== ncToken || !ncRun) { mine.cancel(); return; } + nc = mine; + render(); mine.ready.then((signer) => { if (nc !== mine || !ncRun) return; ui.nostrConnectOpen = false; @@ -179,6 +187,7 @@ export function nostrLoginFeature(ctx) { function stopNostrConnect() { if (nc) { nc.cancel(); nc = null; } ncRun = null; + ncToken = null; } function nostrConnectSection(run) { @@ -188,7 +197,9 @@ export function nostrLoginFeature(ctx) { onClick: () => { ui.nostrConnectOpen = true; startNostrConnect(run); render(); }, }, t('nlConnectApp')); } - if (!nc) return null; + // the nip46 module is still fetching — hold the spot with a spinner + if (!nc) return h('div', { class: 'row gap6', style: 'align-items:center;justify-content:center;padding:8px' }, + h('span', { class: 'spinner sm' })); return h('div', { class: 'col', style: 'gap:10px;align-items:center' }, h('a', { class: 'btn btn-block btn-primary', href: nc.uri, -- cgit v1.2.3