mail page imap connection 12
This commit is contained in:
parent
790e7ed940
commit
47f86057b2
@ -41,22 +41,31 @@ interface Email {
|
||||
category: string;
|
||||
}
|
||||
|
||||
// Update MIME decoding function for better formatting
|
||||
// Improve MIME decoding function
|
||||
const decodeMimeContent = (content: string) => {
|
||||
try {
|
||||
// Extract the actual content after headers
|
||||
const contentMatch = content.match(/charset="utf-8"\s*([\s\S]*?)(?=\s*(?:\[LINK:|$))/);
|
||||
if (!contentMatch) return content;
|
||||
|
||||
let cleanContent = contentMatch[1]
|
||||
// Remove MIME headers and metadata
|
||||
const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, '')
|
||||
.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
|
||||
// Clean up special characters
|
||||
.replace(/=C2=A0/g, ' ')
|
||||
.replace(/=\n/g, '')
|
||||
.replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
|
||||
.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
|
||||
// Remove formatting markers
|
||||
.replace(/\[IMG:.*?\]/g, '')
|
||||
.replace(/\*([^*]+)\*/g, '$1')
|
||||
// Clean up links
|
||||
.replace(/\[ LINK: (.*?) \]/g, '$1')
|
||||
// Normalize whitespace
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
return contentWithoutHeaders;
|
||||
return cleanContent;
|
||||
} catch (error) {
|
||||
console.error('Error decoding MIME content:', error);
|
||||
return content;
|
||||
@ -309,11 +318,11 @@ export default function MailPage() {
|
||||
{/* Sidebar */}
|
||||
<div className={`${sidebarOpen ? 'w-72' : 'w-20'} bg-white/95 backdrop-blur-sm border-0 shadow-lg flex flex-col transition-all duration-300 ease-in-out
|
||||
${mobileSidebarOpen ? 'fixed inset-y-0 left-0 z-40' : 'hidden'} md:block`}>
|
||||
{/* Mail Title */}
|
||||
{/* Courrier Title */}
|
||||
<div className="p-3 border-b border-gray-100">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mail className="h-5 w-5 text-gray-600" />
|
||||
<span className="font-semibold text-gray-900">Mail</span>
|
||||
<Mail className="h-6 w-6 text-gray-600" />
|
||||
<span className="text-xl font-semibold text-gray-900">COURRIER</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -330,7 +339,8 @@ export default function MailPage() {
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Accounts Section */}
|
||||
{/* Accounts Section with Scrollable Content */}
|
||||
<div className="flex flex-col min-h-0 flex-1">
|
||||
<div className="p-3 border-b border-gray-100">
|
||||
<Button
|
||||
variant="ghost"
|
||||
@ -363,10 +373,13 @@ export default function MailPage() {
|
||||
className="w-full justify-between px-2 py-1.5 text-sm group"
|
||||
onClick={() => setSelectedAccount(account.id)}
|
||||
>
|
||||
<div className="flex flex-col items-start">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className={`w-2.5 h-2.5 rounded-full ${account.color}`}></div>
|
||||
<span className="font-medium">{account.name}</span>
|
||||
</div>
|
||||
<span className="text-xs text-gray-500 ml-4">{account.email}</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@ -424,8 +437,10 @@ export default function MailPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex-1 overflow-y-auto py-2">
|
||||
{/* Scrollable Navigation */}
|
||||
<div className="overflow-y-auto flex-1">
|
||||
<nav className="p-3">
|
||||
{/* Navigation items */}
|
||||
<ul className="space-y-0.5 px-2">
|
||||
<li>
|
||||
<Button
|
||||
@ -505,6 +520,8 @@ export default function MailPage() {
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main content */}
|
||||
<div className="flex-1 flex overflow-hidden">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user