From 59cd71ff935b36aa1298ae1a9ede516930890ef9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 29 Oct 2026 13:26:11 -0700 Subject: names: GET /hats/worn lists every head wearing a hat (a couple of dozen), so coinos holds the whole list and a face it has never seen gets its hat in the first paint instead of after a per-head lookup Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6TUeqTyZB8eXLGymUY --- names/server.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'names') diff --git a/names/server.js b/names/server.js index ec60e86..0829c47 100644 --- a/names/server.js +++ b/names/server.js @@ -1578,6 +1578,19 @@ Bun.serve({ return json({ hats }); } + // Every head wearing a hat, in one go (a couple of dozen today): the + // client holds the whole list, so a face it has never seen gets its hat + // in the first paint instead of after a lookup. + if (url.pathname === '/hats/worn' && req.method === 'GET') { + const net = hatNetOf(url.searchParams.get('net')); + const hats = {}; + for (const pk of [...Object.keys(hatStore(net)), HAT_ADMIN_PK]) { + const e = hatRec(pk, net).equipped; + if (e) hats[pk] = e; + } + return json({ hats }); + } + // The shop view: everything one pubkey owns, plus the price list (the // client shows what the server would actually charge). const hm = url.pathname.match(/^\/hats\/([0-9a-f]{64})$/); -- cgit v1.2.3