diff options
author | dan <dan.abramov@gmail.com> | 2024-05-28 16:37:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 16:37:51 +0100 |
commit | 9bd411c15159609803c4e8c3e352a9db32ea527c (patch) | |
tree | 31305e290bd4597aa6ab441ecc556999b19ad693 /src/screens/Onboarding/util.ts | |
parent | 8a2f43c218c464e6165f331e482b6094b87eefc7 (diff) | |
download | voidsky-9bd411c15159609803c4e8c3e352a9db32ea527c.tar.zst |
Replace getAgent() with reading agent (#4243)
* Replace getAgent() with agent * Replace {agent} with agent
Diffstat (limited to 'src/screens/Onboarding/util.ts')
-rw-r--r-- | src/screens/Onboarding/util.ts | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts index fde4316e9..417417707 100644 --- a/src/screens/Onboarding/util.ts +++ b/src/screens/Onboarding/util.ts @@ -66,11 +66,8 @@ export function aggregateInterestItems( return Array.from(new Set(results)).slice(0, 20) } -export async function bulkWriteFollows( - getAgent: () => BskyAgent, - dids: string[], -) { - const session = getAgent().session +export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) { + const session = agent.session if (!session) { throw new Error(`bulkWriteFollows failed: no session`) @@ -89,19 +86,15 @@ export async function bulkWriteFollows( value: r, })) - await getAgent().com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: session.did, writes: followWrites, }) - await whenFollowsIndexed( - getAgent, - session.did, - res => !!res.data.follows.length, - ) + await whenFollowsIndexed(agent, session.did, res => !!res.data.follows.length) } async function whenFollowsIndexed( - getAgent: () => BskyAgent, + agent: BskyAgent, actor: string, fn: (res: AppBskyGraphGetFollows.Response) => boolean, ) { @@ -110,7 +103,7 @@ async function whenFollowsIndexed( 1e3, // 1s delay between tries fn, () => - getAgent().app.bsky.graph.getFollows({ + agent.app.bsky.graph.getFollows({ actor, limit: 1, }), |