Replace getAgent() with reading agent (#4243)

* Replace getAgent() with agent

* Replace {agent} with agent
This commit is contained in:
dan 2024-05-28 16:37:51 +01:00 committed by GitHub
parent 8a2f43c218
commit 9bd411c151
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 400 additions and 438 deletions

View file

@ -30,7 +30,7 @@ export function DisableEmail2FADialog({
const t = useTheme()
const {gtMobile} = useBreakpoints()
const {currentAccount} = useSession()
const {getAgent} = useAgent()
const agent = useAgent()
const [stage, setStage] = useState<Stages>(Stages.Email)
const [confirmationCode, setConfirmationCode] = useState<string>('')
@ -41,7 +41,7 @@ export function DisableEmail2FADialog({
setError('')
setIsProcessing(true)
try {
await getAgent().com.atproto.server.requestEmailUpdate()
await agent.com.atproto.server.requestEmailUpdate()
setStage(Stages.ConfirmCode)
} catch (e) {
setError(cleanError(String(e)))
@ -55,12 +55,12 @@ export function DisableEmail2FADialog({
setIsProcessing(true)
try {
if (currentAccount?.email) {
await getAgent().com.atproto.server.updateEmail({
await agent.com.atproto.server.updateEmail({
email: currentAccount!.email,
token: confirmationCode.trim(),
emailAuthFactor: false,
})
await getAgent().resumeSession(getAgent().session!)
await agent.resumeSession(agent.session!)
Toast.show(_(msg`Email 2FA disabled`))
}
control.close()

View file

@ -13,17 +13,17 @@ export function Email2FAToggle() {
const {currentAccount} = useSession()
const {openModal} = useModalControls()
const disableDialogCtrl = useDialogControl()
const {getAgent} = useAgent()
const agent = useAgent()
const enableEmailAuthFactor = React.useCallback(async () => {
if (currentAccount?.email) {
await getAgent().com.atproto.server.updateEmail({
await agent.com.atproto.server.updateEmail({
email: currentAccount.email,
emailAuthFactor: true,
})
await getAgent().resumeSession(getAgent().session!)
await agent.resumeSession(agent.session!)
}
}, [currentAccount, getAgent])
}, [currentAccount, agent])
const onToggle = React.useCallback(() => {
if (!currentAccount) {

View file

@ -21,11 +21,10 @@ export function ExportCarDialog({
}) {
const {_} = useLingui()
const t = useTheme()
const {getAgent} = useAgent()
const agent = useAgent()
const [loading, setLoading] = React.useState(false)
const download = React.useCallback(async () => {
const agent = getAgent()
if (!agent.session) {
return // shouldnt ever happen
}
@ -49,7 +48,7 @@ export function ExportCarDialog({
setLoading(false)
control.close()
}
}, [_, control, getAgent])
}, [_, control, agent])
return (
<Dialog.Outer control={control}>