diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/messages.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 2351e2b..952350f 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -12946,6 +12946,36 @@ export function messagesFeature(ctx) { // context: a reply shows the post it answers above itself (the // Conversations feed, a profile's Replies tab) — a quote card, which opens // that post; the reply's own tap opens the thread at the reply. + // A really long note (ZeroHedge's run to dozens of lines) shows its first + // ten lines in a feed, fading out, with Show more under it; its thread, and + // a tap on Show more, give the whole thing. "Could you collapse REALLY long + // notes, with a 'more...' link to expand" (npub1muckyme, 2026-11-30). + // Long = more than 16 lines at this screen's width, by estimate, so a + // collapsed note always hides a good part of itself, never a line or two. + const NOTE_CLAMP_OVER = 16; + const noteExpanded = new Set(); + function noteLines(text) { + const w = Math.min((typeof window !== 'undefined' && window.innerWidth) || 400, 680); + const perLine = Math.max(24, Math.floor((w - 90) / 9.5)); // 18px text + let n = 0; + for (const para of String(text || '').split('\n')) n += Math.max(1, Math.ceil(para.length / perLine)); + return n; + } + function noteTextBlock(ev, open, focus) { + const clampable = open && !focus; + const text = ev.kind === ARTICLE ? '' : momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev)); + const clamp = clampable && ev.kind !== ARTICLE && !noteExpanded.has(ev.id) && noteLines(text) > NOTE_CLAMP_OVER; + const body = h('div', { class: 'note-text' + (clamp ? ' note-clamped' : ''), style: 'white-space:pre-wrap;overflow-wrap:anywhere' }, + momentLink(ev), + ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(text, 0, noteEmojiTags(ev)))); + if (!clamp) return body; + return h('div', { class: 'note-clamp-wrap' }, body, + h('button', { + class: 'note-more', type: 'button', + onClick: (e) => { e.stopPropagation(); noteExpanded.add(ev.id); render(); }, + }, t('showMore'))); + } + function noteRow(pk, ev, name, { open = true, focus = false, joined = false, context = false } = {}) { if (ev.kind === REPOST) { const inner = repostInner(ev); @@ -13052,9 +13082,7 @@ export function messagesFeature(ctx) { zapText(ev) ? h('div', {}, ...noteBody(zapText(ev))) : null) : foreign ? h('div', { class: 'note-text small muted', style: 'white-space:pre-wrap;overflow-wrap:anywhere' }, (ev.kind === 64 ? '\u265f ' : '') + altText) - : h('div', { class: 'note-text', style: 'white-space:pre-wrap;overflow-wrap:anywhere' }, - momentLink(ev), - ...(ev.kind === ARTICLE ? (open ? [articleCard(ev)] : articleBody(ev)) : noteBody(momentStripped(ev, shownTranslation(ev)?.text ?? noteText(ev)), 0, noteEmojiTags(ev)))), + : noteTextBlock(ev, open, focus), foreign || pending ? null : translateLine(ev), ev.kind === POLL ? pollBox(ev) : null, pending ? null : noteActions(pk, ev, { canZap }), |
