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 {
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]);