Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
Svelte
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768<script lang="ts"> import { getAuth } from "$lib/auth.svelte"; 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"; import type { MarkupContext } from "$lib/markup/paths";
interface Props { threads: CommentThread[]; subjectUri: string; subjectCid?: string; markup: MarkupContext; class?: string; }
let { threads = $bindable(), subjectUri, subjectCid, markup, 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-4", className]}> <CommentList {threads} {subjectUri} {subjectCid} {markup} {onsubmitted} {onedited} {ondeleted} />
{#if auth.currentDid} <CommentBox {subjectUri} {subjectCid} authorDid={auth.currentDid} authorHandle={auth.currentUser?.handle ?? ""} {markup} {onsubmitted} /> {:else} <SignupPrompt /> {/if}</div>