import { useInfiniteQuery } from '@tanstack/react-query'; import { HistoryIcon } from 'lucide-react'; import { Notice } from '#/components/atoms/notice.jsx'; import { Panel } from '#/components/atoms/panel.jsx'; import { Skeleton } from '#/components/atoms/skeleton.jsx'; import { ActivityList } from '#/components/molecules/activity-list.jsx'; import { EmptyState } from '#/components/molecules/empty-state.jsx'; import { TextLink } from '#/components/molecules/text-link.jsx'; import { get } from '#/lib/api.js'; import { queryKeys } from '#/lib/query.js'; export function HistoryPage({ recordHref, onNavigate }) { const { data, error, isPending, hasNextPage, fetchNextPage, isFetchingNextPage, } = useInfiniteQuery({ queryKey: queryKeys.activity, queryFn: ({ pageParam }) => get( pageParam ? `/activity?limit=40&cursor=${encodeURIComponent(pageParam)}` : '/activity?limit=40', ), initialPageParam: null, getNextPageParam: (last) => last.cursor ?? undefined, }); if (error) return {error.message}; if (isPending) { return (
{['a', 'b', 'c', 'd', 'e', 'f'].map((key) => (
))}
); } const events = data.pages.flatMap((page) => page.events); if (events.length === 0) { return ( } title="No history yet" description="Every record an app adds, changes or removes will be listed here, newest first." /> ); } return (

This is the activity this server has kept. It stays here and does not move with your account if you change hosts.

{hasNextPage && ( fetchNextPage()} disabled={isFetchingNextPage} > {isFetchingNextPage ? 'Loading…' : 'Load more'} )}
); }