import { Client, simpleFetchHandler } from "@atcute/client"; import { createResource, createSignal, For, Show } from "solid-js"; import { Button } from "../components/button"; const LIMIT = 1000; const BlobView = (props: { pds: string; repo: string }) => { const [cursor, setCursor] = createSignal(); let rpc: Client; const fetchBlobs = async () => { if (!rpc) rpc = new Client({ handler: simpleFetchHandler({ service: props.pds }) }); const res = await rpc.get("com.atproto.sync.listBlobs", { params: { did: props.repo as `did:${string}:${string}`, limit: LIMIT, cursor: cursor(), }, }); if (!res.ok) throw new Error(res.data.error); if (!res.data.cids) return []; setCursor(res.data.cids.length < LIMIT ? undefined : res.data.cursor); setBlobs(blobs()?.concat(res.data.cids) ?? res.data.cids); return res.data.cids; }; const [response, { refetch }] = createResource(fetchBlobs); const [blobs, setBlobs] = createSignal(); return (
{(cid) => ( {cid} )}

{blobs()?.length} blob{(blobs()?.length ?? 0 > 1) ? "s" : ""}

); }; export { BlobView };