diff --git a/docs/API.md b/docs/API.md index 24d1706..243b466 100644 --- a/docs/API.md +++ b/docs/API.md @@ -13,7 +13,6 @@ - [useManyMembers](#usemanymembers) - [useIconUrl](#useiconurl) - [useAttachmentUrl](#useattachmenturl) -- [useDocumentCreatedBy](#usedocumentcreatedby) - [useOwnRoleInProject](#useownroleinproject) - [useAddServerPeer](#useaddserverpeer) - [useRemoveServerPeer](#useremoveserverpeer) @@ -361,32 +360,6 @@ function VideoExample() { ``` -### useDocumentCreatedBy - -Retrieve the device ID that created a document. - -| Function | Type | -| ---------- | ---------- | -| `useDocumentCreatedBy` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => { data: string; 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 20c5204..bc86a0a 100644 --- a/src/hooks/projects.ts +++ b/src/hooks/projects.ts @@ -21,7 +21,6 @@ import { createBlobMutationOptions, createProjectMutationOptions, disconnectSyncServersMutationOptions, - documentCreatedByQueryOptions, exportGeoJSONMutationOptions, exportZipFileMutationOptions, getMembersQueryKey, @@ -345,41 +344,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( - documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId }), - ) - - 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 d73eeb0..54b12e4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,7 +32,6 @@ export { useCreateProject, useDataSyncProgress, useDisconnectSyncServers, - useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, diff --git a/src/lib/react-query/projects.ts b/src/lib/react-query/projects.ts index 1281045..8b3a341 100644 --- a/src/lib/react-query/projects.ts +++ b/src/lib/react-query/projects.ts @@ -53,22 +53,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 @@ -179,29 +163,6 @@ export function projectOwnRoleQueryOptions({ }) } -export function documentCreatedByQueryOptions({ - projectApi, - projectId, - originalVersionId, -}: { - projectApi: MapeoProjectApi - projectId: string - originalVersionId: string -}) { - return queryOptions({ - ...baseQueryOptions(), - queryKey: getDocumentCreatedByQueryKey({ - projectId, - originalVersionId, - }), - queryFn: async () => { - return projectApi.$originalVersionIdToDeviceId(originalVersionId) - }, - staleTime: 'static', - gcTime: Infinity, - }) -} - // Used as a placeholder so that we can read the server port from the $blobs.getUrl() method const FAKE_BLOB_ID: BlobApi.BlobId = { type: 'photo',