mail page ui correction maj compose 10
This commit is contained in:
parent
c2395e51d1
commit
2dc237e733
@ -641,7 +641,7 @@ export default function MailPage() {
|
||||
|
||||
// Parse the original email content using MIME decoder
|
||||
const parsedEmail = parseFullEmail(selectedEmailData.body);
|
||||
const decodedBody = parsedEmail.text || parsedEmail.html || selectedEmailData.body;
|
||||
const decodedBody = parsedEmail?.text || parsedEmail?.html || selectedEmailData.body;
|
||||
|
||||
// Format the date properly
|
||||
const emailDate = new Date(selectedEmailData.date).toLocaleString('en-US', {
|
||||
@ -662,22 +662,44 @@ export default function MailPage() {
|
||||
|
||||
case 'replyAll':
|
||||
to = selectedEmailData.from;
|
||||
// Extract CC addresses from the original email, excluding our own address
|
||||
const originalCc = selectedEmailData.cc || '';
|
||||
|
||||
// Get our email address from the selected account
|
||||
const ourEmail = accounts.find(acc => acc.id === selectedEmailData.accountId)?.email || '';
|
||||
const ccAddresses = originalCc
|
||||
.split(',')
|
||||
|
||||
// Handle CC addresses
|
||||
const ccList = new Set<string>();
|
||||
|
||||
// Add original TO recipients (except ourselves and the person we're replying to)
|
||||
selectedEmailData.to.split(',')
|
||||
.map(addr => addr.trim())
|
||||
.filter(addr => addr !== ourEmail && addr !== selectedEmailData.from);
|
||||
cc = ccAddresses.join(', ');
|
||||
.filter(addr => addr !== ourEmail && addr !== selectedEmailData.from)
|
||||
.forEach(addr => ccList.add(addr));
|
||||
|
||||
// Add original CC recipients (if any)
|
||||
if (selectedEmailData.cc) {
|
||||
selectedEmailData.cc.split(',')
|
||||
.map(addr => addr.trim())
|
||||
.filter(addr => addr !== ourEmail && addr !== selectedEmailData.from)
|
||||
.forEach(addr => ccList.add(addr));
|
||||
}
|
||||
|
||||
// Convert Set to string
|
||||
cc = Array.from(ccList).join(', ');
|
||||
|
||||
// If we have CC recipients, show the CC field
|
||||
if (cc) {
|
||||
setShowCc(true);
|
||||
}
|
||||
|
||||
content = `\n\nOn ${emailDate}, ${selectedEmailData.fromName} wrote:\n> ${decodedBody.split('\n').join('\n> ')}`;
|
||||
break;
|
||||
|
||||
case 'forward':
|
||||
// Include original attachments if any
|
||||
const attachmentInfo = parsedEmail.attachments.length > 0
|
||||
// Safely handle attachments
|
||||
const attachments = parsedEmail?.attachments || [];
|
||||
const attachmentInfo = attachments.length > 0
|
||||
? '\n\n-------- Attachments --------\n' +
|
||||
parsedEmail.attachments.map(att => att.filename).join('\n')
|
||||
attachments.map(att => att.filename).join('\n')
|
||||
: '';
|
||||
|
||||
content = `\n\n---------- Forwarded message ----------\n` +
|
||||
@ -687,6 +709,11 @@ export default function MailPage() {
|
||||
`To: ${selectedEmailData.to}\n` +
|
||||
(selectedEmailData.cc ? `Cc: ${selectedEmailData.cc}\n` : '') +
|
||||
`\n\n${decodedBody}${attachmentInfo}`;
|
||||
|
||||
// Handle attachments if present
|
||||
if (attachments.length > 0) {
|
||||
handleForwardedAttachments(attachments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -695,19 +722,6 @@ export default function MailPage() {
|
||||
setComposeTo(to);
|
||||
setComposeCc(cc);
|
||||
setComposeBody(content);
|
||||
|
||||
// Show CC field if there are CC recipients
|
||||
if (cc) {
|
||||
setShowCc(true);
|
||||
}
|
||||
|
||||
// Handle attachments for forwarded emails
|
||||
if (type === 'forward' && parsedEmail.attachments.length > 0) {
|
||||
// You'll need to implement attachment handling here
|
||||
// This could involve creating File objects from the attachment data
|
||||
// or storing the attachment information to be processed when sending
|
||||
handleForwardedAttachments(parsedEmail.attachments);
|
||||
}
|
||||
};
|
||||
|
||||
// Handle forwarded attachments
|
||||
@ -717,13 +731,17 @@ export default function MailPage() {
|
||||
encoding: string;
|
||||
content: string;
|
||||
}>) => {
|
||||
// Store attachment information in state
|
||||
setAttachments(attachments.map(att => ({
|
||||
name: att.filename,
|
||||
type: att.contentType,
|
||||
content: att.content,
|
||||
encoding: att.encoding
|
||||
})));
|
||||
try {
|
||||
// Store attachment information in state
|
||||
setAttachments(attachments.map(att => ({
|
||||
name: att.filename,
|
||||
type: att.contentType,
|
||||
content: att.content,
|
||||
encoding: att.encoding
|
||||
})));
|
||||
} catch (error) {
|
||||
console.error('Error handling attachments:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Modified send function to handle MIME encoding
|
||||
@ -743,12 +761,12 @@ export default function MailPage() {
|
||||
];
|
||||
|
||||
// Add attachments if any
|
||||
if (attachments.length > 0) {
|
||||
if (attachments && attachments.length > 0) {
|
||||
for (const attachment of attachments) {
|
||||
mimeContent = mimeContent.concat([
|
||||
`--${boundary}`,
|
||||
`Content-Type: ${attachment.type}`,
|
||||
`Content-Transfer-Encoding: base64`,
|
||||
`Content-Transfer-Encoding: ${attachment.encoding}`,
|
||||
`Content-Disposition: attachment; filename="${attachment.name}"`,
|
||||
'',
|
||||
attachment.content,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user