From b70e169bb5b5beccb89fd59427726e32d414b4a5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 7 Oct 2026 08:27:39 -0700 Subject: Emoji packs fetch again; a like paints before the author's relays are found Two fetchPack declarations shared messagesFeature's scope since the follow packs arrived (19ac1c4): the later one won, so adding an emoji pack from its chat link (and pulling the packs on a synced kind 10030) asked for a follow pack with undefined fields and always came back "bad pack". The emoji one is fetchEmojiPack now. reactTo awaited the author's relay list (up to 3.5 s for an author with none cached) before painting the reaction it promises "on screen before the relays answer"; the lookup now only gates the publish. Co-Authored-By: Claude Opus 5.5 --- src/features/messages.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/features/messages.js b/src/features/messages.js index f98df3a..f558bce 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -209,7 +209,7 @@ export function messagesFeature(ctx) { saveEmoji(); } const emojiRelays = (extra = []) => [...new Set([...extra, ...zapRelays(), ...DM_RELAYS, ...STOCK_RELAYS])]; - async function fetchPack(ref) { + async function fetchEmojiPack(ref) { // (not fetchPack: that name is the follow packs' further down, and a second declaration wins) const evs = await queryOn(emojiRelays(ref.relays), { kinds: [EMOJI_SET_KIND], authors: [ref.pubkey], '#d': [ref.identifier] }, 6000).catch(() => []); const newest = (evs || []).sort((a, b) => b.created_at - a.created_at)[0]; return newest ? parseEmojiSet(newest) : null; @@ -230,7 +230,7 @@ export function messagesFeature(ctx) { const addr = packAddr(ref.pubkey, ref.identifier); if (hasPack(addr)) { toast(t('msgEmojiPackHave')); return true; } ui.emojiBusy = true; render(); - const pack = await fetchPack(ref); + const pack = await fetchEmojiPack(ref); ui.emojiBusy = false; if (!pack) { toast(t('msgEmojiPackBad')); render(); return false; } holdPack(pack); @@ -287,7 +287,7 @@ export function messagesFeature(ctx) { let changed = false; for (const addr of want) { if (s.packs[addr]) continue; - const pack = await fetchPack(parsePackAddr(addr)); + const pack = await fetchEmojiPack(parsePackAddr(addr)); if (pack) { holdPack(pack); changed = true; } else s.unfetched.push(addr); } // the list's own order wins over arrival order @@ -7726,7 +7726,6 @@ export function messagesFeature(ctx) { async function reactTo(ev, emoji) { const id = await requireIdentity(); - const relays = await noteRelaysFor(ev); const partial = { kind: 7, content: emoji || '❤️', created_at: Math.floor(Date.now() / 1000), tags: [['e', ev.id], ['p', ev.pubkey], ...reactEmojiTags(emoji), CLIENT_TAG], @@ -7735,7 +7734,8 @@ export function messagesFeature(ctx) { myReactEv.set(ev.id, evt.id); noteEvent(evt); // on screen before the relays answer render(); - publishOn(relays, evt).catch(() => {}); + // (the author's relay list can take seconds to find: it isn't needed to paint) + publishOn(await noteRelaysFor(ev), evt).catch(() => {}); } // A boost is kind 6 carrying the note it repeats (NIP-18). -- cgit v1.2.3