(
nodes: TreeNodeData[],
depth: number,
)
| 103 | const newChildrenMap = new Map<string, TreeNodeData[]>(); |
| 104 | |
| 105 | async function expandLevel( |
| 106 | nodes: TreeNodeData[], |
| 107 | depth: number, |
| 108 | ): Promise<void> { |
| 109 | if (depth >= autoExpandDepth || cancelled) return; |
| 110 | const expandable = nodes.filter((n) => isExpandable(n)); |
| 111 | const childResults = await Promise.all( |
| 112 | expandable.map(async (n) => { |
| 113 | const children = await dataProvider.fetchChildren(n.id, n.type); |
| 114 | return { parentId: n.id, children }; |
| 115 | }), |
| 116 | ); |
| 117 | if (cancelled) return; |
| 118 | for (const { parentId, children } of childResults) { |
| 119 | newChildrenMap.set(parentId, children); |
| 120 | if (children.length > 0) newExpandedIds.add(parentId); |
| 121 | } |
| 122 | const allChildren = childResults.flatMap((r) => r.children); |
| 123 | await expandLevel(allChildren, depth + 1); |
| 124 | } |
| 125 | |
| 126 | await expandLevel(fetchedRoots, 0); |
| 127 | if (!cancelled) { |
no test coverage detected