import { useQuery } from '@tanstack/react-query'; import { ServerIcon } from 'lucide-react'; import { Avatar } from '#/components/atoms/avatar.jsx'; import { Button } from '#/components/atoms/button.jsx'; import { Heading } from '#/components/atoms/heading.jsx'; import { Notice } from '#/components/atoms/notice.jsx'; import { Panel } from '#/components/atoms/panel.jsx'; import { ActivityList } from '#/components/molecules/activity-list.jsx'; import { AppCard } from '#/components/molecules/app-card.jsx'; import { Section } from '#/components/molecules/section.jsx'; import { StatTile } from '#/components/molecules/stat-tile.jsx'; import { TextLink } from '#/components/molecules/text-link.jsx'; import { updateHref } from '#/components/organisms/version-card.jsx'; import { get } from '#/lib/api.js'; import { groupByApp, mergeApps, num } from '#/lib/format.js'; import { queryKeys } from '#/lib/query.js'; export function HomePage({ data, onNavigate, appHref, recordHref }) { const { handle, did, hostname, displayName, avatarUrl, stats, collections } = data; const go = onNavigate || (() => {}); // Only for its alias map, so a combined app shows as one card here too. The // cards render from the record buckets alone before it arrives. const { data: appsData } = useQuery({ queryKey: queryKeys.apps, queryFn: () => get('/apps'), }); const apps = appsData?.aliases ? mergeApps(collections, [], appsData.aliases).sort( (a, b) => b.count - a.count, ) : groupByApp(collections); const { data: activity } = useQuery({ queryKey: ['activity', { limit: 6 }], queryFn: () => get('/activity?limit=6'), }); // Answered from the server's cached registry check, so this costs one // same-origin request and stays quiet unless there is news. const { data: version } = useQuery({ queryKey: queryKeys.version, queryFn: () => get('/version'), }); return (
{version?.updateAvailable && ( Server update available. {' '} This server runs pds.js {version.current}, and {version.latest} is out.{' '} {version.updateUrl ? ( <> Update this server {' '} to install it.{' '} ) : ( <>Update the server deployment to install it. )} Release notes )}
{(displayName || handle || did).slice(0, 1).toUpperCase()} } />
{displayName || (handle ? `@${handle}` : 'Your account')}
{handle ? `@${handle}` : did}
Hosted by{' '} {hostname}
{apps.length > 0 && (
See all → } >
{apps.slice(0, 6).map((app) => ( ))}
)}
Full history → } > {activity?.events?.length ? ( ) : (
Nothing to show yet

As apps write to your account, the changes will appear here, newest first.

)}
Where your account is stored
{hostname}
Your home server

Someone has to keep your account online. Yours is kept by {hostname} , which holds your data and hands it to any app you sign in to.

Hosts can be run by an app maker, by a community, or by you.

); }