feat: auto-fetch full email content when an email is auto-selected

This commit is contained in:
Linus Rath
2026-03-14 21:47:50 +01:00
parent a9a8710909
commit f149501dff
+14
View File
@@ -109,6 +109,7 @@ export default function Home() {
selectKeyword,
hasMoreEmails,
fetchTagCounts,
fetchEmailContent,
} = useEmailStore();
// Keyboard shortcuts handlers
@@ -336,6 +337,19 @@ export default function Home() {
};
}, [isAuthenticated, client, mailboxes.length, fetchMailboxes, fetchEmails, fetchQuota, fetchTagCounts, handleStateChange, setPushConnected]);
// Auto-fetch full email content when an email is auto-selected (e.g. after delete/archive)
useEffect(() => {
if (!selectedEmail || !client) return;
// If the email lacks bodyValues, it was auto-selected from the list and needs full content
if (!selectedEmail.bodyValues) {
setLoadingEmail(true);
fetchEmailContent(client, selectedEmail.id).finally(() => {
setLoadingEmail(false);
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedEmail?.id]);
// Handle mark-as-read with delay based on settings
useEffect(() => {
// Clear any existing timeout when email changes