Browse Source

Fix data flow between publication tree and ToC

master
buttercat1791 9 months ago
parent
commit
2d6d38b3b3
  1. 8
      src/lib/components/publications/TableOfContents.svelte
  2. 4
      src/lib/components/publications/table_of_contents.svelte.ts
  3. 1
      src/lib/data_structures/publication_tree.ts

8
src/lib/components/publications/TableOfContents.svelte

@ -40,13 +40,7 @@
} }
entry.expanded = expanded; entry.expanded = expanded;
if (entry.childrenResolved) { entry.resolveChildren();
return;
}
if (expanded) {
entry.resolveChildren();
}
} }
function handleEntryClick(address: string, expanded: boolean = false) { function handleEntryClick(address: string, expanded: boolean = false) {

4
src/lib/components/publications/table_of_contents.svelte.ts

@ -148,8 +148,8 @@ export class TableOfContents {
}); });
// Set up an observer to handle progressive resolution of the publication tree. // Set up an observer to handle progressive resolution of the publication tree.
this.#publicationTree.onNodeResolved(async (address: string) => { this.#publicationTree.onNodeResolved((address: string) => {
await this.#buildTocEntryFromResolvedNode(address); this.#buildTocEntryFromResolvedNode(address);
}); });
} }

1
src/lib/data_structures/publication_tree.ts

@ -623,7 +623,6 @@ export class PublicationTree implements AsyncIterable<NDKEvent | null> {
this.addEventByAddress(address, event); this.addEventByAddress(address, event);
} }
// TODO: We may need to move this to `#addNode`, so the observer is notified more eagerly.
this.#nodeResolvedObservers.forEach(observer => observer(address)); this.#nodeResolvedObservers.forEach(observer => observer(address));
return node; return node;

Loading…
Cancel
Save