migrate the email request mutations to the pds client
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
import {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
|
import {com} from '#/lexicons'
|
||||||
|
|
||||||
export function useRequestEmailUpdate() {
|
export function useRequestEmailUpdate() {
|
||||||
const agent = useAgent()
|
const client = usePdsClient()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
return (await agent.com.atproto.server.requestEmailUpdate()).data
|
return await client.call(com.atproto.server.requestEmailUpdate)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
|
import {com} from '#/lexicons'
|
||||||
|
|
||||||
export function useRequestEmailVerification() {
|
export function useRequestEmailVerification() {
|
||||||
const agent = useAgent()
|
const client = usePdsClient()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
await agent.com.atproto.server.requestEmailConfirmation()
|
await client.call(com.atproto.server.requestEmailConfirmation)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {msg} from '@lingui/core/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {usePdsClient, useSession} from '#/state/session'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
@@ -16,6 +16,7 @@ import {useIntentDialogs} from '#/components/intents/IntentDialogs'
|
|||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_NATIVE} from '#/env'
|
import {IS_NATIVE} from '#/env'
|
||||||
|
import {com} from '#/lexicons'
|
||||||
|
|
||||||
export function VerifyEmailIntentDialog() {
|
export function VerifyEmailIntentDialog() {
|
||||||
const {verifyEmailDialogControl: control} = useIntentDialogs()
|
const {verifyEmailDialogControl: control} = useIntentDialogs()
|
||||||
@@ -37,7 +38,7 @@ function Inner({}: {control: DialogControlProps}) {
|
|||||||
'loading' | 'success' | 'failure' | 'resent'
|
'loading' | 'success' | 'failure' | 'resent'
|
||||||
>('loading')
|
>('loading')
|
||||||
const [sending, setSending] = useState(false)
|
const [sending, setSending] = useState(false)
|
||||||
const agent = useAgent()
|
const client = usePdsClient()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {mutate: confirmEmail} = useConfirmEmail({
|
const {mutate: confirmEmail} = useConfirmEmail({
|
||||||
onSuccess: () => setStatus('success'),
|
onSuccess: () => setStatus('success'),
|
||||||
@@ -52,7 +53,7 @@ function Inner({}: {control: DialogControlProps}) {
|
|||||||
|
|
||||||
const onPressResendEmail = async () => {
|
const onPressResendEmail = async () => {
|
||||||
setSending(true)
|
setSending(true)
|
||||||
await agent.com.atproto.server.requestEmailConfirmation()
|
await client.call(com.atproto.server.requestEmailConfirmation)
|
||||||
setSending(false)
|
setSending(false)
|
||||||
setStatus('resent')
|
setStatus('resent')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user