aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/messages.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-31 13:10:07 -0700
committerAdam Soltys <[email protected]>2026-08-31 13:10:07 -0700
commit21418741adfa8d16c53a20a5cc0d2d78a758ed89 (patch)
treebe989ab21ad3e41c90d0f43d8250bbd548378d0e /src/features/messages.js
parent193f49a7a4fb73ef7bfa405c17e8da3ab94f4205 (diff)
downloadcoinosv3-21418741adfa8d16c53a20a5cc0d2d78a758ed89.tar.gz
coinosv3-21418741adfa8d16c53a20a5cc0d2d78a758ed89.zip
Cold boots stop lying for a few seconds: an empty profile answer (relays still dialing) no longer clobbers a remembered avatar with a punk — stale fields hold while the refresh does its rounds — and the ark merge marks coins spent the moment a synced movement or done action names them as consumed inputs, instead of double-counting a sleeping device's view (output merged in, inputs still 'spendable') until the reconcile caught up and the balance visibly ticked
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MrkLsNScXe9b6BviUSdmMr
Diffstat (limited to 'src/features/messages.js')
-rw-r--r--src/features/messages.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index ad83389..c1f6d19 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -263,12 +263,20 @@ export function messagesFeature(ctx) {
if (cur !== undefined && (cur === null || Date.now() - (cur.t || 0) < PROFILE_TTL)) return cur;
profiles.set(pk, cur || null); // null = loading, no fallback art yet
fetchNostrProfile(pk).then((p) => {
- const entry = { ...(p || {}), t: Date.now() };
+ // An empty answer on a cold boot (relays still dialing, the 5s query
+ // came back with nothing) must never clobber a remembered face with a
+ // punk — keep the stale fields and just refresh the clock, so the
+ // known avatar holds while the full-profile fetch does its rounds.
+ const prev = profiles.get(pk);
+ const entry = p ? { ...p, t: Date.now() } : { ...(prev || {}), t: Date.now() };
profiles.set(pk, entry);
persistProfile(pk, entry);
preloadPicture(entry);
scheduleRepaint();
- }).catch(() => profiles.set(pk, { t: Date.now() }));
+ }).catch(() => {
+ const prev = profiles.get(pk);
+ profiles.set(pk, { ...(prev || {}), t: Date.now() });
+ });
return cur || null;
}
const displayName = (pk) => {