diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx
index bb09912a..8175b91f 100644
--- a/app/[locale]/page.tsx
+++ b/app/[locale]/page.tsx
@@ -657,6 +657,42 @@ export default function Home() {
}
};
+ const handleUnreadFilterClick = async (mailboxId: string) => {
+ const isTogglingOff = selectedMailbox === mailboxId && searchFilters.isUnread === true;
+
+ // Select the mailbox if not already selected
+ if (selectedMailbox !== mailboxId) {
+ selectMailbox(mailboxId);
+ selectEmail(null);
+ }
+
+ // On mobile, close sidebar and go to list view
+ if (isMobile) {
+ setSidebarOpen(false);
+ setActiveView("list");
+ }
+
+ // On tablet, show the list again
+ if (isTablet) {
+ setTabletListVisible(true);
+ }
+
+ if (isTogglingOff) {
+ // Disable the unread filter and show all emails
+ clearSearchFilters();
+ if (client) {
+ await fetchEmails(client, mailboxId);
+ }
+ } else {
+ // Enable unread filter
+ clearSearchFilters();
+ setSearchFilters({ isUnread: true });
+ if (client) {
+ await advancedSearch(client);
+ }
+ }
+ };
+
const handleLogout = () => {
logout();
router.push('/login');
@@ -929,6 +965,7 @@ export default function Home() {
selectedKeyword={selectedKeyword}
onMailboxSelect={handleMailboxSelect}
onTagSelect={handleTagSelect}
+ onUnreadFilterClick={handleUnreadFilterClick}
onCompose={() => {
setComposerMode('compose');
setShowComposer(true);
diff --git a/components/layout/sidebar.tsx b/components/layout/sidebar.tsx
index 31d2916d..559f6923 100644
--- a/components/layout/sidebar.tsx
+++ b/components/layout/sidebar.tsx
@@ -46,6 +46,7 @@ interface SidebarProps {
onTagSelect?: (keywordId: string | null) => void;
onCompose?: () => void;
onSidebarClose?: () => void;
+ onUnreadFilterClick?: (mailboxId: string) => void;
className?: string;
}
@@ -84,6 +85,7 @@ function MailboxTreeItem({
onMailboxSelect,
onToggleExpand,
isCollapsed,
+ onUnreadFilterClick,
}: {
node: MailboxNode;
selectedMailbox: string;
@@ -91,6 +93,7 @@ function MailboxTreeItem({
onMailboxSelect?: (id: string) => void;
onToggleExpand: (id: string) => void;
isCollapsed: boolean;
+ onUnreadFilterClick?: (mailboxId: string) => void;
}) {
const t = useTranslations('sidebar');
const tNotifications = useTranslations('notifications');
@@ -188,14 +191,21 @@ function MailboxTreeItem({
{node.name}
{node.unreadEmails > 0 && (
-
+
+
)}
{node.totalEmails}
@@ -217,6 +227,7 @@ function MailboxTreeItem({
onMailboxSelect={onMailboxSelect}
onToggleExpand={onToggleExpand}
isCollapsed={isCollapsed}
+ onUnreadFilterClick={onUnreadFilterClick}
/>
))}
@@ -336,6 +347,7 @@ export function Sidebar({
onTagSelect,
onCompose,
onSidebarClose,
+ onUnreadFilterClick,
className,
}: SidebarProps) {
const { sidebarCollapsed: isCollapsed, toggleSidebarCollapsed } = useUIStore();
@@ -482,6 +494,7 @@ export function Sidebar({
onMailboxSelect={onMailboxSelect}
onToggleExpand={handleToggleExpand}
isCollapsed={isCollapsed}
+ onUnreadFilterClick={onUnreadFilterClick}
/>
))}
>