import { useQuery } from '@tanstack/react-query'; import { ImageOff } from 'lucide-react'; import { useState } from 'react'; import { Button } from '#/components/atoms/button.jsx'; import { Card } from '#/components/atoms/card.jsx'; import { Link } from '#/components/atoms/link.jsx'; import { Notice } from '#/components/atoms/notice.jsx'; import { Skeleton } from '#/components/atoms/skeleton.jsx'; import { Copyable } from '#/components/molecules/copyable.jsx'; import { EmptyState } from '#/components/molecules/empty-state.jsx'; import { RepoScope } from '#/components/molecules/repo-scope.jsx'; import { fileSize } from '#/lib/format.js'; import { href } from '#/lib/navigation.jsx'; import { useSession } from '#/lib/session.jsx'; import { getBlob, listBlobs } from '#/lib/spaces.js'; /** One blob, fetched only when a reader asks to see it. */ function BlobRow({ space, repo, cid }) { const { session } = useSession(); const [open, setOpen] = useState(false); const { data, error, isPending } = useQuery({ queryKey: ['blob', space, repo, cid], queryFn: () => getBlob(session, { space, repo }, cid), enabled: open, retry: false, }); return (
{cid.slice(0, 28)}…
{open && isPending && } {open && error && {error.message}} {open && data && ( <> {data.type.startsWith('image/') && ( {cid} )} {data.type || 'unknown type'} · {fileSize(data.size)} )}
); } export function BlobsPage({ space, repo }) { const { session } = useSession(); const { data, error, isPending } = useQuery({ queryKey: ['blobs', space, repo], queryFn: () => listBlobs(session, { space, repo }), retry: false, }); return (
← Back to the space

Blobs

The blobs this repo's records in the space reference. Reachability is read from the records themselves, so a blob no record names is not listed and is not served.

{isPending && } {error && {error.message}} {data?.cids.length === 0 && ( } title="No blobs" description="No record in this space references one." /> )} {data?.cids.map((cid) => ( ))}
); }