mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 08:06:13 +00:00
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.
13 lines
626 B
TypeScript
13 lines
626 B
TypeScript
/**
|
||
* 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();
|
||
}
|