diff options
author | Eric Bailey <git@esb.lol> | 2024-04-25 15:53:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 21:53:27 +0100 |
commit | e5fdbfe2940e56b491fadade9260a4ce15a24946 (patch) | |
tree | bd9a52b5d9335250b2daa9b041a76a13b4872c45 /src | |
parent | 35005da59e93312874beeb2d937c04801ad958d2 (diff) | |
download | voidsky-e5fdbfe2940e56b491fadade9260a4ce15a24946.tar.zst |
[Session] Drill `getAgent` into `Onboarding/util` (#3704)
* Drill agent into Onboarding/util (cherry picked from commit 2ba68eb5e446a694730b720f2a5b3307eb0914ef) * Thread getAgent instead --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/screens/Onboarding/StepFinished.tsx | 1 | ||||
-rw-r--r-- | src/screens/Onboarding/util.ts | 19 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/screens/Onboarding/StepFinished.tsx b/src/screens/Onboarding/StepFinished.tsx index 56635c672..c7e10ed3d 100644 --- a/src/screens/Onboarding/StepFinished.tsx +++ b/src/screens/Onboarding/StepFinished.tsx @@ -57,6 +57,7 @@ export function StepFinished() { try { await Promise.all([ bulkWriteFollows( + getAgent, suggestedAccountsStepResults.accountDids.concat(BSKY_APP_ACCOUNT_DID), ), // these must be serial diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts index 6b12fb38f..fde4316e9 100644 --- a/src/screens/Onboarding/util.ts +++ b/src/screens/Onboarding/util.ts @@ -1,7 +1,10 @@ -import {AppBskyGraphFollow, AppBskyGraphGetFollows} from '@atproto/api' +import { + AppBskyGraphFollow, + AppBskyGraphGetFollows, + BskyAgent, +} from '@atproto/api' import {until} from '#/lib/async/until' -import {getAgent} from '#/state/session' import {PRIMARY_FEEDS} from './StepAlgoFeeds' function shuffle(array: any) { @@ -63,7 +66,10 @@ export function aggregateInterestItems( return Array.from(new Set(results)).slice(0, 20) } -export async function bulkWriteFollows(dids: string[]) { +export async function bulkWriteFollows( + getAgent: () => BskyAgent, + dids: string[], +) { const session = getAgent().session if (!session) { @@ -87,10 +93,15 @@ export async function bulkWriteFollows(dids: string[]) { repo: session.did, writes: followWrites, }) - await whenFollowsIndexed(session.did, res => !!res.data.follows.length) + await whenFollowsIndexed( + getAgent, + session.did, + res => !!res.data.follows.length, + ) } async function whenFollowsIndexed( + getAgent: () => BskyAgent, actor: string, fn: (res: AppBskyGraphGetFollows.Response) => boolean, ) { |