fix: improve mailbox tree logic #118
This commit is contained in:
@@ -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]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user