Bluesky app fork with some witchin' additions 馃挮
at twelve 28 lines 751 B view raw
1import {useMutation} from '@tanstack/react-query' 2 3import {useAgent, useSession} from '#/state/session' 4 5export function useConfirmEmail({ 6 onSuccess, 7 onError, 8}: {onSuccess?: () => void; onError?: () => void} = {}) { 9 const agent = useAgent() 10 const {currentAccount} = useSession() 11 12 return useMutation({ 13 mutationFn: async ({token}: {token: string}) => { 14 if (!currentAccount?.email) { 15 throw new Error('No email found for the current account') 16 } 17 18 await agent.com.atproto.server.confirmEmail({ 19 email: currentAccount.email.trim(), 20 token: token.trim(), 21 }) 22 // will update session state at root of app 23 await agent.resumeSession(agent.session!) 24 }, 25 onSuccess, 26 onError, 27 }) 28}