Replace getAgent() with reading agent (#4243)
* Replace getAgent() with agent * Replace {agent} with agent
This commit is contained in:
parent
8a2f43c218
commit
9bd411c151
74 changed files with 400 additions and 438 deletions
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue