useDocumentHistory.ts614 BView on GitHub /**
* Lazy hook for the document version-history timeline.
*
* The query only fires when `enabled = true` — wired by the History toolbar
* toggle in the document view. Normal editor load never touches the history
* endpoints.
*/
import { useQuery } from '@tanstack/react-query';
import { useTRPC } from '@/providers/query-provider';
export function useDocumentHistory(
documentId: string | null | undefined,
enabled: boolean,
) {
const trpc = useTRPC();
return useQuery({
...trpc.documents.history.queryOptions({ documentId: documentId ?? '' }),
enabled: enabled && !!documentId,
});
}