Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142import type { Nsid, ResourceUri } 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 ShTangledFeedReaction from "$lib/api/lexicons/types/sh/tangled/feed/reaction";
export type ReactionRecord = ShTangledFeedReaction.Main;
export const REACTION_COLLECTION = "sh.tangled.feed.reaction" as Nsid;
export const putReaction = async ( agent: OAuthUserAgent, rkey: string, record: ReactionRecord): Promise<RecordView<ReactionRecord>> => { const { uri, cid } = await putRecord(agent, REACTION_COLLECTION, rkey, record); return { uri, cid, value: record };};
export const deleteReaction = async ( agent: OAuthUserAgent, rkey: string): Promise<{ uri: ResourceUri }> => { const uri = `at://${agent.sub}/${REACTION_COLLECTION}/${rkey}` as ResourceUri; await deleteRecord(agent, REACTION_COLLECTION, rkey); return { uri };};
export interface ReactionListPage { cursor?: string | null; items: RecordView<ReactionRecord>[];}
export const listReactions = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit) => jsonGet<ReactionListPage>(ctx, "sh.tangled.feed.listReactions", { subject, ...filter }, init);