update follows when pressing follow all (#4663)
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
AppBskyGraphGetFollows,
|
||||
BskyAgent,
|
||||
} from '@atproto/api'
|
||||
import {TID} from '@atproto/common-web'
|
||||
|
||||
import {until} from '#/lib/async/until'
|
||||
|
||||
@@ -20,9 +21,11 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
||||
createdAt: new Date().toISOString(),
|
||||
}
|
||||
})
|
||||
|
||||
const followWrites = followRecords.map(r => ({
|
||||
$type: 'com.atproto.repo.applyWrites#create',
|
||||
collection: 'app.bsky.graph.follow',
|
||||
rkey: TID.nextStr(),
|
||||
value: r,
|
||||
}))
|
||||
|
||||
@@ -31,6 +34,15 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
||||
writes: followWrites,
|
||||
})
|
||||
await whenFollowsIndexed(agent, session.did, res => !!res.data.follows.length)
|
||||
|
||||
const followUris = new Map()
|
||||
for (const r of followWrites) {
|
||||
followUris.set(
|
||||
r.value.subject,
|
||||
`at://${session.did}/app.bsky.graph.follow/${r.rkey}`,
|
||||
)
|
||||
}
|
||||
return followUris
|
||||
}
|
||||
|
||||
async function whenFollowsIndexed(
|
||||
|
||||
Reference in New Issue
Block a user