"use client"; import { useRouter } from "next/navigation"; import { ActionButton } from "@/components/ui/action-button"; import { Separator } from "@/components/ui/separator"; import LoadingSpinner from "@/components/ui/spinner"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { toast } from "@/components/ui/use-toast"; import { useClientConfig } from "@/lib/clientConfig"; import { api } from "@/lib/trpc"; import { keepPreviousData, useQuery } from "@tanstack/react-query"; import { Trash } from "lucide-react"; import { useSession } from "next-auth/react"; const REPO_LATEST_RELEASE_API = "https://api.github.com/repos/hoarder-app/hoarder/releases/latest"; const REPO_RELEASE_PAGE = "https://github.com/hoarder-app/hoarder/releases"; function useLatestRelease() { const { data } = useQuery({ queryKey: ["latest-release"], queryFn: async () => { const res = await fetch(REPO_LATEST_RELEASE_API); if (!res.ok) { return undefined; } const data = (await res.json()) as { name: string }; return data.name; }, staleTime: 60 * 60 * 1000, enabled: !useClientConfig().disableNewReleaseCheck, }); return data; } function ReleaseInfo() { const currentRelease = useClientConfig().serverVersion ?? "not set"; const latestRelease = useLatestRelease(); let newRelease; if (latestRelease && currentRelease != latestRelease) { newRelease = ( (New release available: {latestRelease}) ); } return (
{currentRelease} {newRelease}
); } function ActionsSection() { const { mutate: recrawlLinks, isPending: isRecrawlPending } = api.admin.recrawlLinks.useMutation({ onSuccess: () => { toast({ description: "Recrawl enqueued", }); }, onError: (e) => { toast({ variant: "destructive", description: e.message, }); }, }); const { mutate: reindexBookmarks, isPending: isReindexPending } = api.admin.reindexAllBookmarks.useMutation({ onSuccess: () => { toast({ description: "Reindex enqueued", }); }, onError: (e) => { toast({ variant: "destructive", description: e.message, }); }, }); return ( <>Actions
Server Stats
Background Jobs
Users
Admin