From 8f3ef61e4fbaf8c7cf586ed1280fd8f4bdc624ae Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 15 Sep 2026 09:33:36 -0700 Subject: A reply's quoted line shows its custom emoji as pictures. The quote above a reply bubble, the composer's reply bar, and the same on the public /chat page rendered the raw :shortcode:. They now run the one-line snippet through the same NIP-30 tokenizer, cutting on text so a shortcode is never sliced in half. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01JuwQqNWtDJcxPWtEm9134z --- src/public-chat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/public-chat.js') diff --git a/src/public-chat.js b/src/public-chat.js index 4d79010..91ded5b 100644 --- a/src/public-chat.js +++ b/src/public-chat.js @@ -45,6 +45,12 @@ const LINK_SPLIT = /(https?:\/\/[^\s]+|nostr:(?:npub|nprofile|note|nevent|naddr) const emojiImg = (code, url) => h('img', { class: 'cemoji', src: url, alt: ':' + code + ':', title: ':' + code + ':', loading: 'lazy' }); // `em` is the message's ["emoji", code, url] map; a :code: it names renders // as its picture, anything else stays text +// a reply's quoted line: one line, cut at 90, its custom emoji as pictures +function quoteNodes(rumor) { + const em = emojiTagMap(rumor && rumor.tags); + const one = String((rumor && rumor.content) || '').replace(/\s+/g, ' ').trim().slice(0, 90); + return splitEmoji(one, (c) => em.get(c)).map((p) => (typeof p === 'string' ? p : emojiImg(p.code, p.url))); +} function linkedBody(text, em = null) { const out = []; const emojiAt = em && em.size ? (c) => em.get(c) : null; @@ -263,8 +269,7 @@ export function mountPublicChat() { ? (byChannel.get(activeChannel) || new Map()).get(replyId) : null; const quote = replySrc ? h('div', { class: 'chat-quote' }, h('span', { class: 'chat-quote-name' }, nameOf(replySrc.author)), - h('span', { class: 'chat-quote-text' }, - String(replySrc.rumor.content || '').replace(/\s+/g, ' ').slice(0, 90))) : null; + h('span', { class: 'chat-quote-text' }, ...quoteNodes(replySrc.rumor))) : null; log.append(h('div', { class: 'chat-row' + (grouped ? ' grouped' : '') }, grouped ? h('div', { class: 'chat-avatar spacer' }) : avatar(m.author), h('div', { class: 'chat-body' }, -- cgit v1.2.3