import 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> => { const { uri, cid } = await putRecord(agent, COMMENT_COLLECTION, rkey, record); return { uri, cid, value: record }; }; export const deleteComment = async (agent: OAuthUserAgent, rkey: string): Promise => { await deleteRecord(agent, COMMENT_COLLECTION, rkey); }; export interface CommentListPage { cursor?: string | null; items: RecordView[]; } export const listComments = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit ) => jsonGet(ctx, "sh.tangled.feed.listComments", { subject, ...filter }, init);