mail page imap connection mime 5 bis rest 2

This commit is contained in:
alma 2025-04-15 22:44:45 +02:00
parent 23a152ffbc
commit bdb9e2922b

View File

@ -427,9 +427,11 @@ export default function MailPage() {
throw new Error('Failed to fetch emails');
}
const data = await response.json();
setEmails(data);
// Ensure data is an array
setEmails(Array.isArray(data) ? data : []);
} catch (err) {
setError(err instanceof Error ? err.message : 'An error occurred');
setEmails([]); // Set empty array on error
} finally {
setLoading(false);
}
@ -450,7 +452,7 @@ export default function MailPage() {
];
// Filter emails based on current view
const filteredEmails = emails.filter(email => {
const filteredEmails = Array.isArray(emails) ? emails.filter(email => {
if (selectedAccount === 0) return true;
return email.accountId === selectedAccount.toString();
}).filter(email => {
@ -466,7 +468,7 @@ export default function MailPage() {
default:
return true;
}
});
}) : [];
// Format date for display
const formatDate = (dateString: string) => {