diff options
| author | Adam Soltys <[email protected]> | 2026-08-18 08:20:14 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-18 08:20:14 -0700 |
| commit | f684cee551fc2d2470f518332597dd9072a7da90 (patch) | |
| tree | a015ee1380e944d093724c1b03abff99be0f5a7d /src | |
| parent | 4465314218b95b8a4962a76f420867b9b670ec12 (diff) | |
| download | coinosv3-f684cee551fc2d2470f518332597dd9072a7da90.tar.gz coinosv3-f684cee551fc2d2470f518332597dd9072a7da90.zip | |
The restored shop remembers to go shopping: a session that wakes on the hat screen refetches its data instead of filtering a collection nobody loaded — the crash that bricked every tap on the phone
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/hats.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/features/hats.js b/src/features/hats.js index ed89a82..4f6e977 100644 --- a/src/features/hats.js +++ b/src/features/hats.js @@ -194,8 +194,12 @@ export function hatsFeature(ctx) { function openShop() { ui.hatShop = true; - ui.hatShopData = null; ui.hatConfirm = null; + loadShop(); + } + + function loadShop() { + ui.hatShopData = null; render(); const me = ctx.shownPubkey(); if (!me) { ui.hatShopData = { owned: [], equipped: null }; render(); return; } @@ -309,12 +313,12 @@ export function hatsFeature(ctx) { h('div', { class: 'card col', style: 'gap:12px' }, h('h3', { style: 'margin:0' }, '🎩 ' + t('hatShopTitle')), h('p', { class: 'small muted', style: 'margin:0' }, t('hatShopBlurb')), - d === null + d == null ? h('div', { style: 'text-align:center;padding:16px' }, h('span', { class: 'spinner' })) : h('div', { class: 'col', style: 'gap:2px' }, // the crown is not merchandise — it appears only in the // collection of the head that owns it, never as a listing - ...HATS.filter((hat) => hat.id !== 'crown' || (d.owned || []).includes('crown')) + ...HATS.filter((hat) => hat.id !== 'crown' || ((d && d.owned) || []).includes('crown')) .map((hat) => shopRow(hat, d, me))), d && d.offline ? h('div', { class: 'small faint', style: 'text-align:center' }, t('hatShopOffline')) : null), h('button', { class: 'btn-ghost btn-block', onClick: closeShop }, t('back'))); @@ -339,6 +343,11 @@ export function hatsFeature(ctx) { }, screenView() { if (ui.screen !== 'wallet' || !ui.hatShop) return null; + // A restored session brings the shop screen back WITHOUT its data + // (hatShop rides the nav snapshot; the fetch result doesn't) — refetch + // instead of rendering a collection nobody loaded. undefined = never + // fetched; null = fetch in flight. + if (ui.hatShopData === undefined) setTimeout(loadShop, 0); return shopScreen(); }, }; |
