courrier multi account restore compose
This commit is contained in:
parent
e7890356e1
commit
b62ae2d849
@ -69,35 +69,30 @@ export default function EmailPanel({
|
||||
const [isComposing, setIsComposing] = useState<boolean>(false);
|
||||
const [composeType, setComposeType] = useState<'new' | 'reply' | 'reply-all' | 'forward'>('new');
|
||||
|
||||
// Create a formatted version of the email content using the same formatter as ComposeEmail
|
||||
// Create a formatted version of the email content
|
||||
const formattedEmail = useMemo(() => {
|
||||
if (!email) return null;
|
||||
|
||||
try {
|
||||
// Convert to the formatter message format - this is what ComposeEmail does
|
||||
const formatterEmail: FormatterEmailMessage = {
|
||||
id: email.id,
|
||||
messageId: email.messageId,
|
||||
subject: email.subject,
|
||||
from: email.from || [],
|
||||
to: email.to || [],
|
||||
cc: email.cc || [],
|
||||
bcc: email.bcc || [],
|
||||
date: email.date,
|
||||
content: email.content,
|
||||
html: email.html,
|
||||
text: email.text,
|
||||
hasAttachments: email.hasAttachments || false
|
||||
};
|
||||
// Handle different content structures
|
||||
let content = '';
|
||||
|
||||
// Get the formatted content
|
||||
const formattedContent = email.content || email.html || email.text || '';
|
||||
if (typeof email.content === 'string') {
|
||||
// Direct string content
|
||||
content = email.content;
|
||||
} else if (email.content && typeof email.content === 'object') {
|
||||
// Object with text/html properties
|
||||
content = email.content.html || email.content.text || '';
|
||||
} else {
|
||||
// Fallback to html or text properties
|
||||
content = email.html || email.text || '';
|
||||
}
|
||||
|
||||
// Return a new email object with the formatted content
|
||||
return {
|
||||
...email,
|
||||
content: formattedContent,
|
||||
formattedContent
|
||||
content,
|
||||
formattedContent: content
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error formatting email content:', error);
|
||||
|
||||
@ -105,37 +105,33 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
|
||||
.slice(0, 2);
|
||||
};
|
||||
|
||||
// Format the email content using the same formatter as ComposeEmail
|
||||
// Format the email content
|
||||
const formattedContent = useMemo(() => {
|
||||
if (!email) return '';
|
||||
|
||||
try {
|
||||
// Convert to the formatter message format - same as what ComposeEmail does
|
||||
const formatterEmail: FormatterEmailMessage = {
|
||||
id: email.id,
|
||||
messageId: email.messageId,
|
||||
subject: email.subject,
|
||||
from: email.from || [],
|
||||
to: email.to || [],
|
||||
cc: email.cc || [],
|
||||
bcc: email.bcc || [],
|
||||
date: email.date instanceof Date ? email.date : new Date(email.date),
|
||||
content: email.content || '',
|
||||
html: email.html,
|
||||
text: email.text,
|
||||
hasAttachments: email.hasAttachments || false
|
||||
};
|
||||
// Get the content in order of preference
|
||||
let content = '';
|
||||
|
||||
// Get the formatted content - if already formatted content is provided, use that instead
|
||||
if (email.formattedContent) {
|
||||
return email.formattedContent;
|
||||
content = email.formattedContent;
|
||||
} else if (typeof email.content === 'string') {
|
||||
content = email.content;
|
||||
} else if (email.content && typeof email.content === 'object') {
|
||||
content = email.content.html || email.content.text || '';
|
||||
} else {
|
||||
content = email.html || email.text || '';
|
||||
}
|
||||
|
||||
// Otherwise sanitize the content for display
|
||||
return sanitizeHtml(email.content || email.html || email.text || '');
|
||||
// Sanitize the content for display
|
||||
return sanitizeHtml(content, {
|
||||
ADD_TAGS: ['table', 'thead', 'tbody', 'tr', 'td', 'th'],
|
||||
ADD_ATTR: ['target', 'rel', 'colspan', 'rowspan', 'style', 'class', 'id', 'border'],
|
||||
ALLOW_DATA_ATTR: false
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error formatting email content:', error);
|
||||
return email.content || email.html || email.text || '';
|
||||
return '';
|
||||
}
|
||||
}, [email]);
|
||||
|
||||
@ -241,7 +237,7 @@ export default function EmailPreview({ email, loading = false, onReply }: EmailP
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Email content - using the preformatted content */}
|
||||
{/* Email content */}
|
||||
<ScrollArea className="flex-1">
|
||||
<div className="space-y-2 p-6">
|
||||
<div className="border rounded-md overflow-hidden">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user