From 6ce1a9c483150905e924d5755208cd309b169840 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 17 Apr 2025 14:45:39 +0200 Subject: [PATCH] solve mail backend 15 --- app/api/mail/route.ts | 11 ++----- components/mail/mail-list.tsx | 55 +++++++++++++++++------------------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/app/api/mail/route.ts b/app/api/mail/route.ts index 277981ef..ed816f44 100644 --- a/app/api/mail/route.ts +++ b/app/api/mail/route.ts @@ -51,17 +51,11 @@ export async function GET() { // Fetch only essential message data const messages = await client.fetch('1:20', { envelope: true, - flags: true, - bodyStructure: true, - bodyParts: ['TEXT'] + flags: true }); const result = []; for await (const message of messages) { - // Get the message content - const content = await client.download(message.uid.toString(), 'TEXT'); - const body = content?.content?.toString() || ''; - result.push({ id: message.uid.toString(), from: message.envelope.from[0].address, @@ -69,8 +63,7 @@ export async function GET() { date: message.envelope.date.toISOString(), read: message.flags.has('\\Seen'), starred: message.flags.has('\\Flagged'), - folder: mailbox.path, - body: body + folder: mailbox.path }); } diff --git a/components/mail/mail-list.tsx b/components/mail/mail-list.tsx index 21eca8b6..7b63a854 100644 --- a/components/mail/mail-list.tsx +++ b/components/mail/mail-list.tsx @@ -17,42 +17,41 @@ export function MailList({ mails, onMailClick }: MailListProps) { } return ( -
+
{mails.map((mail) => (
onMailClick(mail)} > -
-
-
-
- {mail.from} -
- {mail.starred && ( - - )} -
-
- {mail.subject} -
-
- {mail.body} -
- {mail.attachments && mail.attachments.length > 0 && ( -
- - {mail.attachments.length} attachment{mail.attachments.length !== 1 ? 's' : ''} -
+
+
+ {mail.starred ? ( + + ) : ( + )} + {mail.from}
-
- {format(new Date(mail.date), 'MMM d, yyyy')} -
+ + {format(new Date(mail.date), "MMM d, yyyy")} +
+
+

{mail.subject}

+

+ {mail.body} +

+
+ {mail.attachments && mail.attachments.length > 0 && ( +
+ + {mail.attachments.length} attachment + {mail.attachments.length > 1 ? "s" : ""} +
+ )}
))}