Files
native/src/lib/single-line.ts
T
Linus Rath d45c7996d2 fix: keep list previews and subjects on one line
Previews keep the body's paragraph breaks, so a line-clamped row showed
a dangling "…" line and rows came out at uneven heights, and a subject
carrying CR/LF rendered over several lines in the list and the viewer.
Fold every whitespace run to a single space before display with a new
`singleLine` helper, in the mailbox and unified inbox rows, the viewer
subject and the collapsed thread card preview.
2026-09-24 18:50:55 +02:00

13 lines
626 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Fold a server string onto one line for display: every run of whitespace
* (CR/LF, tabs, repeated spaces) becomes a single space and the ends are
* trimmed. Message previews keep the body's paragraph breaks and a subject
* can carry a stray CR/LF; on a line-clamped Text those left a dangling
* "…" line and uneven row heights, and an unclamped subject wrapped over
* several lines. A lone no-break space is kept so "12 %" doesn't split.
*/
export function singleLine(text: string | null | undefined): string {
if (!text) return '';
return text.replace(/\s+/g, (run) => (run === ' ' ? run : ' ')).trim();
}