From 790e7ed9408c79a9f18024f91142bdf4027a26fb Mon Sep 17 00:00:00 2001 From: alma Date: Tue, 15 Apr 2025 21:33:43 +0200 Subject: [PATCH] mail page imap connection 11 --- app/mail/page.tsx | 217 ++++++++++++++++++++++++---------------------- 1 file changed, 113 insertions(+), 104 deletions(-) diff --git a/app/mail/page.tsx b/app/mail/page.tsx index 3191052..830c70d 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -41,22 +41,22 @@ interface Email { category: string; } -// Add MIME decoding function +// Update MIME decoding function for better formatting const decodeMimeContent = (content: string) => { try { - // Remove MIME headers - const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, ''); - - // Decode quoted-printable - const decoded = contentWithoutHeaders + // Remove MIME headers and metadata + const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, '') + .replace(/---InfomaniakPhpMail.*?Content-Transfer-Encoding:.*?\n/g, '') + .replace(/=C2=A0/g, ' ') // Replace non-breaking spaces .replace(/=\n/g, '') // Remove soft line breaks .replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))) - .replace(/=C2=A0/g, ' ') // Replace non-breaking spaces - .replace(/\[LINK: (.*?)\]/g, '$1') // Format links - .replace(/\[IMG: (.*?)\]/g, '') // Remove image placeholders + .replace(/\[IMG:.*?\]/g, '') // Remove image placeholders + .replace(/\[LINK:\s*(.*?)\s*\]/g, '$1') // Clean up links + .replace(/\*([^*]+)\*/g, '$1') // Remove asterisks + .replace(/\s+/g, ' ') // Normalize whitespace .trim(); - return decoded; + return contentWithoutHeaders; } catch (error) { console.error('Error decoding MIME content:', error); return content; @@ -309,111 +309,120 @@ export default function MailPage() { {/* Sidebar */}
- {/* Courrier Title */} + {/* Mail Title */}
- - Courrier + + Mail
- {/* Accounts Section */} -
-
Accounts
- - {/* All Accounts Option */} - - - {/* Mail Accounts List */} - {accounts.map(account => ( -
- - - - {/* Account Actions Dropdown */} - {showAccountActions === account.id && ( -
- - -
- )} -
- ))} - - {/* Add Account Button */} - -
- {/* Compose button */} - +
+ + {/* Accounts Section */} +
+ + + {accountsDropdownOpen && ( +
+ {/* All Accounts Option */} + + + {/* Mail Accounts List */} + {accounts.map(account => ( +
+ + + + {/* Account Actions Dropdown */} + {showAccountActions === account.id && ( +
+ + +
+ )} +
+ ))} + + {/* Add Account Button */} + +
)} - +
{/* Navigation */}