Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
843 B · 30 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031import {useMutation} from '@tanstack/react-query'
import {usePdsClient, useSession, useSessionApi} from '#/state/session'import {com} from '#/lexicons'
export function useConfirmEmail({ onSuccess, onError,}: {onSuccess?: () => void; onError?: () => void} = {}) { const pdsClient = usePdsClient() const {currentAccount} = useSession() const {refreshSession} = useSessionApi()
return useMutation({ mutationFn: async ({token}: {token: string}) => { if (!currentAccount?.email) { throw new Error('No email found for the current account') }
await pdsClient.call(com.atproto.server.confirmEmail, { email: currentAccount.email.trim(), token: token.trim(), }) // will update session state at root of app await refreshSession() }, onSuccess, onError, })}