aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--names/server.js13
1 files changed, 13 insertions, 0 deletions
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})$/);