diff --git a/app/mail/page.tsx b/app/mail/page.tsx index 2a59ef4..cabb2d2 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -1550,9 +1550,17 @@ export default function MailPage() { } const data = await response.json(); setEmails(data.emails); - // Only update unread count if we're in the Inbox + + // Only update unread count when switching to Inbox if (newMailbox === 'INBOX') { setUnreadCount(data.unreadCount); + } else { + // Keep the existing unread count when switching to other folders + const inboxResponse = await fetch('/api/mail?folder=INBOX'); + if (inboxResponse.ok) { + const inboxData = await inboxResponse.json(); + setUnreadCount(inboxData.unreadCount); + } } } catch (err) { setError(err instanceof Error ? err.message : 'Failed to fetch emails');