Browse Source

Add a `getParent` abstraction to `SveltePublicationTree`

master
buttercat1791 9 months ago
parent
commit
d3a62c13f6
  1. 8
      src/lib/components/publications/svelte_publication_tree.svelte.ts

8
src/lib/components/publications/svelte_publication_tree.svelte.ts

@ -28,6 +28,14 @@ export class SveltePublicationTree { @@ -28,6 +28,14 @@ export class SveltePublicationTree {
return this.#publicationTree.getHierarchy(address);
}
async getParent(address: string): Promise<NDKEvent | null> {
const hierarchy = await this.getHierarchy(address);
// The last element in the hierarchy is the event with the given address, so the parent is the
// second to last element.
return hierarchy.at(-2) ?? null;
}
setBookmark(address: string) {
this.#publicationTree.setBookmark(address);
}

Loading…
Cancel
Save