buttercat1791 10 months ago
parent
commit
af4fae766f
  1. 3
      deno.lock
  2. 5
      src/lib/data_structures/publication_tree.ts

3
deno.lock

@ -3201,8 +3201,10 @@
"npm:@types/d3@^7.4.3", "npm:@types/d3@^7.4.3",
"npm:@types/he@1.2", "npm:@types/he@1.2",
"npm:@types/node@22", "npm:@types/node@22",
"npm:@types/qrcode@^1.5.5",
"npm:asciidoctor@3.0", "npm:asciidoctor@3.0",
"npm:autoprefixer@10", "npm:autoprefixer@10",
"npm:bech32@2",
"npm:d3@^7.9.0", "npm:d3@^7.9.0",
"npm:eslint-plugin-svelte@2", "npm:eslint-plugin-svelte@2",
"npm:flowbite-svelte-icons@2.1", "npm:flowbite-svelte-icons@2.1",
@ -3217,6 +3219,7 @@
"npm:postcss@8", "npm:postcss@8",
"npm:prettier-plugin-svelte@3", "npm:prettier-plugin-svelte@3",
"npm:prettier@3", "npm:prettier@3",
"npm:qrcode@^1.5.4",
"npm:svelte-check@4", "npm:svelte-check@4",
"npm:svelte@5", "npm:svelte@5",
"npm:tailwind-merge@^3.3.0", "npm:tailwind-merge@^3.3.0",

5
src/lib/data_structures/publication_tree.ts

@ -464,6 +464,11 @@ export class PublicationTree implements AsyncIterable<NDKEvent | null> {
} }
#addNode(address: string, parentNode: PublicationTreeNode) { #addNode(address: string, parentNode: PublicationTreeNode) {
if (this.#nodes.has(address)) {
console.debug(`[PublicationTree] Node with address ${address} already exists.`);
return;
}
const lazyNode = new Lazy<PublicationTreeNode>(() => this.#resolveNode(address, parentNode)); const lazyNode = new Lazy<PublicationTreeNode>(() => this.#resolveNode(address, parentNode));
parentNode.children!.push(lazyNode); parentNode.children!.push(lazyNode);
this.#nodes.set(address, lazyNode); this.#nodes.set(address, lazyNode);

Loading…
Cancel
Save