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 @@
// See https://kit.svelte.dev/docs/types#app // 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 // for information about these interfaces
declare global { declare global {
namespace App { namespace App {
@ -9,6 +13,7 @@ declare global {
parser?: Pharos; parser?: Pharos;
waitable?: Promise<any>; waitable?: Promise<any>;
publicationType?: string; publicationType?: string;
publicationRootEvent?: NDKEvent;
} }
// interface Platform {} // interface Platform {}
} }

7
src/routes/publication/+page.svelte

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

1
src/routes/publication/+page.ts

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

Loading…
Cancel
Save