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