fix: improve mailbox tree logic #118

This commit is contained in:
Linus Rath
2026-03-29 23:47:52 +02:00
parent a453f7fa67
commit 2d983c9853
+11 -4
View File
@@ -459,10 +459,17 @@ export function Sidebar({
} }
} else { } else {
const tree = buildMailboxTree(mailboxes); const tree = buildMailboxTree(mailboxes);
const defaultExpanded = tree const collectExpandable = (nodes: MailboxNode[]): string[] => {
.filter(node => node.children.length > 0) const ids: string[] = [];
.map(node => node.id); for (const node of nodes) {
setExpandedFolders(new Set(defaultExpanded)); if (node.children.length > 0) {
ids.push(node.id);
ids.push(...collectExpandable(node.children));
}
}
return ids;
};
setExpandedFolders(new Set(collectExpandable(tree)));
} }
}, [mailboxes]); }, [mailboxes]);