Browse Source

Instanatiate PublicationTree and make it available to components

master
buttercat1791 11 months ago
parent
commit
5486c73685
  1. 5
      src/app.d.ts
  2. 7
      src/routes/publication/+page.svelte
  3. 1
      src/routes/publication/+page.ts

5
src/app.d.ts vendored

@ -1,4 +1,8 @@ @@ -1,4 +1,8 @@
// See https://kit.svelte.dev/docs/types#app
import NDK, { NDKEvent } from "@nostr-dev-kit/ndk";
import Pharos from "./lib/parser.ts";
// for information about these interfaces
declare global {
namespace App {
@ -9,6 +13,7 @@ declare global { @@ -9,6 +13,7 @@ declare global {
parser?: Pharos;
waitable?: Promise<any>;
publicationType?: string;
publicationRootEvent?: NDKEvent;
}
// interface Platform {}
}

7
src/routes/publication/+page.svelte

@ -2,10 +2,15 @@ @@ -2,10 +2,15 @@
import Article from "$lib/components/Publication.svelte";
import { TextPlaceholder } from "flowbite-svelte";
import type { PageData } from "./$types";
import { onDestroy } from "svelte";
import { onDestroy, setContext } from "svelte";
import { PublicationTree } from "$lib/data_structures/publication_tree";
let { data }: { data: PageData } = $props();
const publicationTree = new PublicationTree(data.publicationRootEvent, data.ndk);
setContext('publicationTree', publicationTree);
onDestroy(() => data.parser.reset());
</script>

1
src/routes/publication/+page.ts

@ -102,5 +102,6 @@ export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () => @@ -102,5 +102,6 @@ export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () =>
return {
waitable: fetchPromise,
publicationType,
publicationRootEvent: indexEvent,
};
};

Loading…
Cancel
Save