Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273<script lang="ts"> import { getAuth } from "#lib/auth.svelte.ts"; import type { KnotOrigin } from "#lib/api/syntax.ts"; import CommentBox from "#lib/components/comment/CommentBox.svelte"; import CommentList from "#lib/components/comment/CommentList.svelte"; import SignupPrompt from "#lib/components/ui/SignupPrompt.svelte"; import { insertComment, removeComment, updateComment, type CommentThread, type ThreadInput } from "#lib/components/comment/comments.ts"; import type { MarkupContext } from "#lib/markup/paths.ts";
interface Props { threads: CommentThread[]; subjectUri: string; subjectCid?: string; markup: MarkupContext; knot?: KnotOrigin; class?: string; }
let { threads = $bindable(), subjectUri, subjectCid, markup, knot, class: className = "" }: Props = $props();
const auth = getAuth();
const onsubmitted = (submitted: ThreadInput) => { threads = insertComment(threads, submitted); }; const onedited = (edited: ThreadInput) => { threads = updateComment(threads, edited); }; const ondeleted = (uri: string) => { threads = removeComment(threads, uri); };</script>
<div class={["flex flex-col gap-md", className]}> <CommentList {threads} {subjectUri} {subjectCid} {markup} {knot} {onsubmitted} {onedited} {ondeleted} />
{#if auth.currentDid} <CommentBox {subjectUri} {subjectCid} authorDid={auth.currentDid} authorHandle={auth.currentUser?.handle ?? ""} {markup} {knot} {onsubmitted} /> {:else} <SignupPrompt /> {/if}</div>