Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1import {useMutation} from '@tanstack/react-query'
2
3import {useAgent, useSession} from '#/state/session'
4
5export function useManageEmail2FA() {
6 const agent = useAgent()
7 const {currentAccount} = useSession()
8
9 return useMutation({
10 mutationFn: async ({
11 enabled,
12 token,
13 }:
14 | {enabled: true; token?: undefined}
15 | {enabled: false; token: string}) => {
16 if (!currentAccount?.email) {
17 throw new Error('No email found for the current account')
18 }
19
20 await agent.com.atproto.server.updateEmail({
21 email: currentAccount.email,
22 emailAuthFactor: enabled,
23 token,
24 })
25 // will update session state at root of app
26 await agent.resumeSession(agent.session!)
27 },
28 })
29}