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 */}
- {/* Accounts Section */}
-
-
Accounts
-
- {/* All Accounts Option */}
-
-
- {/* Mail Accounts List */}
- {accounts.map(account => (
-
-
-
- {/* Account Actions Dropdown */}
- {showAccountActions === account.id && (
-
- {
- const newName = prompt('Enter new account name:', account.name);
- if (newName) handleEditAccount(account.id, newName);
- setShowAccountActions(null);
- }}
- >
-
- Modify Account
-
- {
- setDeleteType('account');
- setItemToDelete(account.id);
- setShowDeleteConfirm(true);
- setShowAccountActions(null);
- }}
- >
-
- Remove Account
-
-
- )}
-
- ))}
-
- {/* Add Account Button */}
-
-
- Add Account
-
-
-
{/* Compose button */}
-
setComposeOpen(true)}
- >
- {sidebarOpen ? (
+
+
setComposeOpen(true)}
+ >
- ) : (
-
+
+
+
+ {/* Accounts Section */}
+
+
setAccountsDropdownOpen(!accountsDropdownOpen)}
+ >
+ Accounts
+ {accountsDropdownOpen ? : }
+
+
+ {accountsDropdownOpen && (
+
+ {/* All Accounts Option */}
+
setSelectedAccount(0)}
+ >
+
+
+
+ {/* Mail Accounts List */}
+ {accounts.map(account => (
+
+
setSelectedAccount(account.id)}
+ >
+
+ {
+ e.stopPropagation();
+ setShowAccountActions(account.id);
+ }}
+ >
+
+
+
+
+ {/* Account Actions Dropdown */}
+ {showAccountActions === account.id && (
+
+ {
+ const newName = prompt('Enter new account name:', account.name);
+ if (newName) handleEditAccount(account.id, newName);
+ setShowAccountActions(null);
+ }}
+ >
+
+ Modify Account
+
+ {
+ setDeleteType('account');
+ setItemToDelete(account.id);
+ setShowDeleteConfirm(true);
+ setShowAccountActions(null);
+ }}
+ >
+
+ Remove Account
+
+
+ )}
+
+ ))}
+
+ {/* Add Account Button */}
+
+
+ Add Account
+
+
)}
-
+
{/* Navigation */}