compose mime

This commit is contained in:
alma 2025-04-24 19:20:16 +02:00
parent 079f876674
commit c05c4e71ca

View File

@ -507,24 +507,26 @@ export default function CourrierPage() {
setAvailableFolders(data.folders);
}
// Process emails keeping exact folder names
const processedEmails = (data.emails || []).map((email: any) => ({
id: Number(email.id),
accountId: 1,
from: email.from || '',
fromName: email.fromName || email.from?.split('@')[0] || '',
to: email.to || '',
subject: email.subject || '(No subject)',
body: email.body || '',
date: email.date || new Date().toISOString(),
read: email.read || false,
starred: email.starred || false,
folder: email.folder || currentView,
cc: email.cc,
bcc: email.bcc,
flags: email.flags || [],
raw: email.body || ''
}));
// Process emails keeping exact folder names and sort by date
const processedEmails = (data.emails || [])
.map((email: any) => ({
id: Number(email.id),
accountId: 1,
from: email.from || '',
fromName: email.fromName || email.from?.split('@')[0] || '',
to: email.to || '',
subject: email.subject || '(No subject)',
body: email.body || '',
date: email.date || new Date().toISOString(),
read: email.read || false,
starred: email.starred || false,
folder: email.folder || currentView,
cc: email.cc,
bcc: email.bcc,
flags: email.flags || [],
raw: email.body || ''
}))
.sort((a: Email, b: Email) => new Date(b.date).getTime() - new Date(a.date).getTime());
// Only update unread count if we're in the Inbox folder
if (currentView === 'INBOX') {
@ -535,7 +537,9 @@ export default function CourrierPage() {
}
if (isLoadMore) {
setEmails(prev => [...prev, ...processedEmails]);
setEmails(prev => [...prev, ...processedEmails].sort((a: Email, b: Email) =>
new Date(b.date).getTime() - new Date(a.date).getTime()
));
setPage(prev => prev + 1);
} else {
setEmails(processedEmails);