Get more rigorous about getAgent() consistency (#2026)

* Get more rigorous about getAgent() consistency

* Update the feed wrapper API to use getAgent() directly
This commit is contained in:
Paul Frazee 2023-11-29 10:10:04 -08:00 committed by GitHub
parent 9fb2c29c67
commit 6fe2b52f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 70 additions and 103 deletions

View file

@ -4,7 +4,6 @@ import {
AppBskyActorDefs,
AppBskyActorProfile,
AppBskyActorGetProfile,
BskyAgent,
} from '@atproto/api'
import {useQuery, useQueryClient, useMutation} from '@tanstack/react-query'
import {Image as RNImage} from 'react-native-image-crop-picker'
@ -68,7 +67,7 @@ export function useProfileUpdateMutation() {
}
return existing
})
await whenAppViewReady(getAgent(), profile.did, res => {
await whenAppViewReady(profile.did, res => {
if (typeof newUserAvatar !== 'undefined') {
if (newUserAvatar === null && res.data.avatar) {
// url hasnt cleared yet
@ -464,7 +463,6 @@ function useProfileUnblockMutation() {
}
async function whenAppViewReady(
agent: BskyAgent,
actor: string,
fn: (res: AppBskyActorGetProfile.Response) => boolean,
) {
@ -472,6 +470,6 @@ async function whenAppViewReady(
5, // 5 tries
1e3, // 1s delay between tries
fn,
() => agent.app.bsky.actor.getProfile({actor}),
() => getAgent().app.bsky.actor.getProfile({actor}),
)
}