diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/messages.js | 20 | ||||
| -rw-r--r-- | src/style.css | 5 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index e97fa37..7f71264 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -6901,6 +6901,24 @@ export function messagesFeature(ctx) { return out; } + // A quote inside a quote: one line of who and what, never a third level + // of cards (a bare "view note" link said nothing about where it leads). + function quoteMini(ref) { + let c = feedPaint ? feedPaint.quotes.get(ref.id) : null; + if (!c?.ev) { + c = quotedNote(ref); + if (feedPaint && c.ev) feedPaint.quotes.set(ref.id, { ...c }); + } + const open = (e) => { e.preventDefault(); e.stopPropagation(); if (c.ev) openNoteThread(c.ev); else openNoteRef(ref); }; + if (!c.ev || hidden(c.ev)) return h('a', { href: '#', class: 'quote-mini small', onClick: open }, + t(c.status === 'loading' ? 'noteRefLoading' : 'noteRefLink')); + const words = plainExcerpt(c.ev.content.replace(/https?:\/\/\S+|nostr:(note|nevent|naddr)1[a-z0-9]+/gi, ' ')); + return h('div', { class: 'quote-mini clickable', onClick: open }, + avatar(c.ev.pubkey, 'chat-avatar mini', false), + h('span', { class: 'quote-name' }, displayName(c.ev.pubkey)), + h('span', { class: 'small muted quote-mini-text' }, words || '\u2026')); + } + // One URL, rendered as whatever it points at. `isImage` is markdown saying // so outright — plenty of perfectly good picture URLs carry no extension // (a CDN path, a /media/ route), and ![…] is the author telling us what it @@ -7280,7 +7298,7 @@ export function messagesFeature(ctx) { if (ref && ref.type === 'event') { // the note they're quoting, shown inside what they said about it — // except one level down, where it goes back to being a link - out.push(depth ? h('a', { + out.push(depth === 1 ? quoteMini(ref) : depth ? h('a', { href: '#', onClick: (e) => { e.preventDefault(); e.stopPropagation(); openNoteRef(ref); }, }, t('noteRefLink')) : quoteCard(ref, depth)); } else out.push(h('span', { class: 'faint' }, part.slice(6, 18) + '…')); diff --git a/src/style.css b/src/style.css index 0515a7e..c0edfac 100644 --- a/src/style.css +++ b/src/style.css @@ -811,6 +811,11 @@ html.no-scroll { overflow: hidden; scrollbar-gutter: auto; } .quote-card.clickable { cursor: pointer; } .quote-card.clickable:hover { border-color: var(--line-strong); } .quote-loading { flex-direction: row; align-items: center; gap: 8px; } +/* a quote inside a quote: one line */ +.quote-mini { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 5px 8px; min-width: 0; + border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; overflow: hidden; } +.quote-mini .quote-name { flex-shrink: 0; } +.quote-mini-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; } /* An audio link as a player (a podcast on Blossom, a voice note). */ .note-audio { margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); display: flex; flex-direction: column; gap: 6px; white-space: normal; } |
