( messageId: string, parent: ReplySnapshotParent | null | undefined )
| 144 | |
| 145 | /** |
| 146 | * Short, human-readable single-line preview of a message's content blocks. |
| 147 | * Falls back to attachment filenames (or a mime-typed descriptor) when no |
| 148 | * text is present, so attachment-only messages don't render as empty strings |
| 149 | * in reply previews, conversation list previews, etc. |
| 150 | */ |
| 151 | export function contentBlocksPreviewText(content: Array<PreviewBlock>): string { |
| 152 | const text = contentBlocksToText(content).trim(); |
| 153 | if (text) return text; |
| 154 | const labels = contentBlocksAttachmentPreviewLabels(content); |
| 155 | if (labels.length === 0) return ''; |
| 156 | return labels |
| 157 | .map(label => { |
| 158 | switch (label.kind) { |
| 159 | case 'filename': |
| 160 | return label.filename; |
| 161 | case 'image': |
| 162 | return 'Image'; |
| 163 | case 'attachment': |
| 164 | return 'Attachment'; |
| 165 | } |
| 166 | }) |
| 167 | .join(', '); |
| 168 | } |
no test coverage detected