Skip to content

Commit

Permalink
Merge pull request #152 from jay-hodgson/SWC-6424
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson authored Apr 21, 2023
2 parents ed7aaf7 + 82e1adb commit 45a8d83
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { SynapseClientError } from '../../../SynapseClientError'
import { useSynapseContext } from '../../../SynapseContext'
import { OAuthClient, OAuthClientList } from '../../../synapseTypes/OAuthClient'

const oAuthQueryKeys = {
all: (accessToken: string) => ['oAuthClient', accessToken],
}

export function useGetOAuthClientInfinite(
options?: UseInfiniteQueryOptions<OAuthClientList, SynapseClientError>,
) {
Expand Down Expand Up @@ -79,15 +75,17 @@ export function useCreateOAuthClient(
options?: UseMutationOptions<OAuthClient, SynapseClientError, OAuthClient>,
) {
const queryClient = useQueryClient()
const { accessToken } = useSynapseContext()
const { accessToken, keyFactory } = useSynapseContext()

return useMutation<OAuthClient, SynapseClientError, OAuthClient>(
(client: OAuthClient) =>
SynapseClient.createOAuthClient(client, accessToken!),
{
...options,
onSuccess: async (updatedClient, client, ctx) => {
await queryClient.invalidateQueries(oAuthQueryKeys.all(accessToken!))
await queryClient.invalidateQueries(
keyFactory.getMyOAuthClientsQueryKey(),
)
if (options?.onSuccess) {
await options.onSuccess(updatedClient, client, ctx)
}
Expand Down

0 comments on commit 45a8d83

Please sign in to comment.