From f149501dff20e0612fab5d9421dd6fa4f33baadb Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 14 Mar 2026 21:47:50 +0100 Subject: [PATCH] feat: auto-fetch full email content when an email is auto-selected --- app/[locale]/page.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 8512dbbc..ac1b2959 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -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