Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
- [useManyMembers](#usemanymembers)
- [useIconUrl](#useiconurl)
- [useAttachmentUrl](#useattachmenturl)
- [useDocumentCreatedBy](#usedocumentcreatedby)
- [useOwnRoleInProject](#useownroleinproject)
- [useAddServerPeer](#useaddserverpeer)
- [useRemoveServerPeer](#useremoveserverpeer)
Expand Down Expand Up @@ -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.
Expand Down
45 changes: 0 additions & 45 deletions src/hooks/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
baseMutationOptions,
baseQueryOptions,
filterMutationResult,
getDocumentCreatedByQueryKey,
getMediaServerOriginQueryKey,
getMemberByIdQueryKey,
getMembersQueryKey,
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export {
useCreateProject,
useDataSyncProgress,
useDisconnectSyncServers,
useDocumentCreatedBy,
useIconUrl,
useImportProjectCategories,
useImportProjectConfig,
Expand Down
16 changes: 0 additions & 16 deletions src/lib/react-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading