Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move JS revealPath and openDirRecursive to not await row-by-row #189

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions js/src/contents_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ async function* walkPath<T extends IContentRow>(path: string[], root: Content<T>
*/
export async function revealPath<T extends IContentRow>(contents: ContentsModel<T>, path: string[]): Promise<Content<T>> {
let node: Content<T>;
const promises: Array<Promise<void>> = [];
for await (node of walkPath(path, contents.root)) {
if (!node.isExpand && node.hasChildren) {
await node.expand();
promises.push(node.expand());
}
}
await Promise.all(promises);
return node!;
}

Expand Down Expand Up @@ -84,11 +86,13 @@ export async function revealAndSelectPath<T extends IContentRow>(contents: Conte
* @param path Array of directory names to be opened in order
*/
export async function openDirRecursive<T extends IContentRow>(model: ContentsModel<T>, path: string[]) {
const promises: Array<Promise<void>> = [];
for await (const node of walkPath(path, model.root)) {
if (node.pathstr !== model.root.pathstr) {
await model.openDir(node.row);
promises.push(model.openDir(node.row));
}
}
await Promise.all(promises);
}


Expand Down
Loading