mail page imap connection mime 5 bis rest 2
This commit is contained in:
parent
23a152ffbc
commit
bdb9e2922b
@ -427,9 +427,11 @@ export default function MailPage() {
|
|||||||
throw new Error('Failed to fetch emails');
|
throw new Error('Failed to fetch emails');
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setEmails(data);
|
// Ensure data is an array
|
||||||
|
setEmails(Array.isArray(data) ? data : []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'An error occurred');
|
setError(err instanceof Error ? err.message : 'An error occurred');
|
||||||
|
setEmails([]); // Set empty array on error
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@ -450,7 +452,7 @@ export default function MailPage() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Filter emails based on current view
|
// Filter emails based on current view
|
||||||
const filteredEmails = emails.filter(email => {
|
const filteredEmails = Array.isArray(emails) ? emails.filter(email => {
|
||||||
if (selectedAccount === 0) return true;
|
if (selectedAccount === 0) return true;
|
||||||
return email.accountId === selectedAccount.toString();
|
return email.accountId === selectedAccount.toString();
|
||||||
}).filter(email => {
|
}).filter(email => {
|
||||||
@ -466,7 +468,7 @@ export default function MailPage() {
|
|||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
}) : [];
|
||||||
|
|
||||||
// Format date for display
|
// Format date for display
|
||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user