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 @@ -13,7 +13,6 @@
- [useManyMembers](#usemanymembers)
- [useIconUrl](#useiconurl)
- [useAttachmentUrl](#useattachmenturl)
- [useDocumentCreatedBy](#usedocumentcreatedby)
- [useOwnRoleInProject](#useownroleinproject)
- [useAddServerPeer](#useaddserverpeer)
- [useRemoveServerPeer](#useremoveserverpeer)
Expand Down Expand Up @@ -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.
Expand Down
36 changes: 0 additions & 36 deletions src/hooks/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
createBlobMutationOptions,
createProjectMutationOptions,
disconnectSyncServersMutationOptions,
documentCreatedByQueryOptions,
exportGeoJSONMutationOptions,
exportZipFileMutationOptions,
getMembersQueryKey,
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export {
useCreateProject,
useDataSyncProgress,
useDisconnectSyncServers,
useDocumentCreatedBy,
useIconUrl,
useImportProjectCategories,
useImportProjectConfig,
Expand Down
39 changes: 0 additions & 39 deletions src/lib/react-query/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down