From 2d983c98536afd9f61bd7d04887583106f75da28 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:47:52 +0200 Subject: [PATCH] fix: improve mailbox tree logic #118 --- components/layout/sidebar.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/layout/sidebar.tsx b/components/layout/sidebar.tsx index cb1a22dc..af172b2a 100644 --- a/components/layout/sidebar.tsx +++ b/components/layout/sidebar.tsx @@ -459,10 +459,17 @@ export function Sidebar({ } } else { const tree = buildMailboxTree(mailboxes); - const defaultExpanded = tree - .filter(node => node.children.length > 0) - .map(node => node.id); - setExpandedFolders(new Set(defaultExpanded)); + const collectExpandable = (nodes: MailboxNode[]): string[] => { + const ids: string[] = []; + for (const node of nodes) { + if (node.children.length > 0) { + ids.push(node.id); + ids.push(...collectExpandable(node.children)); + } + } + return ids; + }; + setExpandedFolders(new Set(collectExpandable(tree))); } }, [mailboxes]);