Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637import type { Nsid } from "@atcute/lexicons/syntax";import type { OAuthUserAgent } from "@atcute/oauth-browser-client";import type { BobbinContext, XrpcRequestInit } from "$lib/api/client";import { jsonGet } from "$lib/api/_request";import type { RecordView } from "$lib/api/records";import { deleteRecord, putRecord } from "$lib/api/write";import type * as ShTangledFeedComment from "$lib/api/lexicons/types/sh/tangled/feed/comment";
export type CommentRecord = ShTangledFeedComment.Main;
const COMMENT_COLLECTION = "sh.tangled.feed.comment" as Nsid;
export const putComment = async ( agent: OAuthUserAgent, rkey: string, record: CommentRecord): Promise<RecordView<CommentRecord>> => { const { uri, cid } = await putRecord(agent, COMMENT_COLLECTION, rkey, record); return { uri, cid, value: record };};
export const deleteComment = async (agent: OAuthUserAgent, rkey: string): Promise<void> => { await deleteRecord(agent, COMMENT_COLLECTION, rkey);};
export interface CommentListPage { cursor?: string | null; items: RecordView<CommentRecord>[];}
export const listComments = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit) => jsonGet<CommentListPage>(ctx, "sh.tangled.feed.listComments", { subject, ...filter }, init);