From 70e7674a774a9384935c6da5e38d04e4221faee9 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Tue, 8 Jul 2025 09:18:11 -0500 Subject: [PATCH] Parallelize ToC initialization step --- .../publications/table_of_contents.svelte.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/components/publications/table_of_contents.svelte.ts b/src/lib/components/publications/table_of_contents.svelte.ts index aaf3ac3..6c07f66 100644 --- a/src/lib/components/publications/table_of_contents.svelte.ts +++ b/src/lib/components/publications/table_of_contents.svelte.ts @@ -155,11 +155,12 @@ export class TableOfContents { this.addressMap.set(rootAddress, this.#root); - // TODO: Parallelize this. - // Handle any other nodes that have already been resolved. - this.#publicationTree.resolvedAddresses.forEach((address) => { - this.#buildTocEntryFromResolvedNode(address); - }); + // Handle any other nodes that have already been resolved in parallel. + await Promise.all( + Array.from(this.#publicationTree.resolvedAddresses).map((address) => + this.#buildTocEntryFromResolvedNode(address) + ) + ); // Set up an observer to handle progressive resolution of the publication tree. this.#publicationTree.onNodeResolved((address: string) => {