courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 15:31:52 +02:00
parent efbc11bee1
commit 3b455d33d4

View File

@ -17,6 +17,8 @@ interface EmailListItemProps {
onToggleStarred: (e: React.MouseEvent) => void; onToggleStarred: (e: React.MouseEvent) => void;
} }
const PREVIEW_LENGTH = 70;
export default function EmailListItem({ export default function EmailListItem({
email, email,
isSelected, isSelected,
@ -96,23 +98,26 @@ export default function EmailListItem({
}; };
// Get preview text from email content // Get preview text from email content
const getPreviewText = () => { const getPreviewText = (content: { text: string; html: string } | string) => {
if (email.preview) return email.preview; let text = '';
let content = email.content || ''; if (typeof content === 'string') {
text = content;
// Strip HTML tags if present } else {
content = content.replace(/<[^>]+>/g, ' '); // Prefer text content if available, fall back to HTML
text = content.text || content.html;
// Clean up whitespace
content = content.replace(/\s+/g, ' ').trim();
// Limit to ~70 chars
if (content.length > 70) {
return content.substring(0, 70) + '...';
} }
return content || 'No preview available'; // Strip HTML tags if present
text = text.replace(/<[^>]+>/g, ' ');
// Clean up whitespace
text = text.replace(/\s+/g, ' ').trim();
// Truncate to preview length
return text.length > PREVIEW_LENGTH
? text.substring(0, PREVIEW_LENGTH) + '...'
: text;
}; };
return ( return (
@ -155,7 +160,7 @@ export default function EmailListItem({
</h3> </h3>
<div className="text-xs text-gray-500 truncate"> <div className="text-xs text-gray-500 truncate">
{getPreviewText()} {getPreviewText(email.content)}
</div> </div>
</div> </div>
</div> </div>