From 59299540d19009648da42bc4d49eb35b1221fecd Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 1 Dec 2025 10:56:23 -0500 Subject: [PATCH] feat!: remove useDocumentCreatedBy hook --- docs/API.md | 27 ------------------------- src/hooks/projects.ts | 45 ------------------------------------------ src/index.ts | 1 - src/lib/react-query.ts | 16 --------------- 4 files changed, 89 deletions(-) diff --git a/docs/API.md b/docs/API.md index 05496d4..c9fb9a3 100644 --- a/docs/API.md +++ b/docs/API.md @@ -25,7 +25,6 @@ - [useManyMembers](#usemanymembers) - [useIconUrl](#useiconurl) - [useAttachmentUrl](#useattachmenturl) -- [useDocumentCreatedBy](#usedocumentcreatedby) - [useOwnRoleInProject](#useownroleinproject) - [useAddServerPeer](#useaddserverpeer) - [useRemoveServerPeer](#useremoveserverpeer) @@ -512,32 +511,6 @@ function VideoExample() { ``` -### useDocumentCreatedBy - -Retrieve the device ID that created a document. - -| Function | Type | -| ---------- | ---------- | -| `useDocumentCreatedBy` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => { data: any; error: Error or null; isRefetching: boolean; }` | - -Parameters: - -* `opts.projectId`: Project public ID -* `opts.originalVersionId`: Version ID of document - - -Examples: - -```tsx -function BasicExample() { - const { data } = useDocumentCreatedBy({ - projectId: '...', - originalVersionId: '...', - }) -} -``` - - ### useOwnRoleInProject Get the role for the current device in a specified project. diff --git a/src/hooks/projects.ts b/src/hooks/projects.ts index 8f2cfc5..65cbb6c 100644 --- a/src/hooks/projects.ts +++ b/src/hooks/projects.ts @@ -18,7 +18,6 @@ import { baseMutationOptions, baseQueryOptions, filterMutationResult, - getDocumentCreatedByQueryKey, getMediaServerOriginQueryKey, getMemberByIdQueryKey, getMembersQueryKey, @@ -389,50 +388,6 @@ function useMediaServerOrigin({ projectApi }: { projectApi: MapeoProjectApi }) { return { data, error, isRefetching } } -// TODO: Eventually remove in favor of this information being provided by the backend when retrieving documents -/** - * Retrieve the device ID that created a document. - * - * @param opts.projectId Project public ID - * @param opts.originalVersionId Version ID of document - * - * @example - * ```tsx - * function BasicExample() { - * const { data } = useDocumentCreatedBy({ - * projectId: '...', - * originalVersionId: '...', - * }) - * } - * ``` - * - * @deprecated Use `createdBy` field from document read hooks. - */ -export function useDocumentCreatedBy({ - projectId, - originalVersionId, -}: { - projectId: string - originalVersionId: string -}) { - const { data: projectApi } = useSingleProject({ projectId }) - - const { data, error, isRefetching } = useSuspenseQuery({ - ...baseQueryOptions(), - queryKey: getDocumentCreatedByQueryKey({ - projectId, - originalVersionId, - }), - queryFn: async () => { - return projectApi.$originalVersionIdToDeviceId(originalVersionId) - }, - staleTime: 'static', - gcTime: Infinity, - }) - - return { data, error, isRefetching } -} - /** * Get the role for the current device in a specified project. * This is a more convenient alternative to using the `useOwnDeviceInfo` and `useManyMembers` hooks. diff --git a/src/index.ts b/src/index.ts index d1325fa..b180e8e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,7 +61,6 @@ export { useCreateProject, useDataSyncProgress, useDisconnectSyncServers, - useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, diff --git a/src/lib/react-query.ts b/src/lib/react-query.ts index fb3a1d3..dc142dd 100644 --- a/src/lib/react-query.ts +++ b/src/lib/react-query.ts @@ -175,22 +175,6 @@ export function getMemberByIdQueryKey({ return [ROOT_QUERY_KEY, 'projects', projectId, 'members', deviceId] as const } -export function getDocumentCreatedByQueryKey({ - projectId, - originalVersionId, -}: { - projectId: string - originalVersionId: string -}) { - return [ - ROOT_QUERY_KEY, - 'projects', - projectId, - 'document_created_by', - originalVersionId, - ] as const -} - /** * We call this within a project hook, because that's the only place the API is * exposed right now, but it is the same for all projects, so no need for