Add attribution for starter pack follows (#9834)
This commit is contained in:
@@ -96,10 +96,13 @@ export function StepFinished() {
|
|||||||
const {selectedInterests} = interestsStepResults
|
const {selectedInterests} = interestsStepResults
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
bulkWriteFollows(agent, [
|
bulkWriteFollows(
|
||||||
BSKY_APP_ACCOUNT_DID,
|
agent,
|
||||||
...(listItems?.map(i => i.subject.did) ?? []),
|
[BSKY_APP_ACCOUNT_DID, ...(listItems?.map(i => i.subject.did) ?? [])],
|
||||||
]),
|
starterPack
|
||||||
|
? {uri: starterPack.uri, cid: starterPack.cid}
|
||||||
|
: undefined,
|
||||||
|
),
|
||||||
(async () => {
|
(async () => {
|
||||||
// Interests need to get saved first, then we can write the feeds to prefs
|
// Interests need to get saved first, then we can write the feeds to prefs
|
||||||
await agent.setInterestsPref({tags: selectedInterests})
|
await agent.setInterestsPref({tags: selectedInterests})
|
||||||
|
|||||||
@@ -72,7 +72,10 @@ export function StarterPackCard({
|
|||||||
|
|
||||||
let followUris: Map<string, string>
|
let followUris: Map<string, string>
|
||||||
try {
|
try {
|
||||||
followUris = await bulkWriteFollows(agent, dids)
|
followUris = await bulkWriteFollows(agent, dids, {
|
||||||
|
uri: view.uri,
|
||||||
|
cid: view.cid,
|
||||||
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
Toast.show(_(msg`An error occurred while trying to follow all`), {
|
Toast.show(_(msg`An error occurred while trying to follow all`), {
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ import {
|
|||||||
type AppBskyGraphGetFollows,
|
type AppBskyGraphGetFollows,
|
||||||
type BskyAgent,
|
type BskyAgent,
|
||||||
type ComAtprotoRepoApplyWrites,
|
type ComAtprotoRepoApplyWrites,
|
||||||
|
type ComAtprotoRepoStrongRef,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {TID} from '@atproto/common-web'
|
import {TID} from '@atproto/common-web'
|
||||||
import chunk from 'lodash.chunk'
|
import chunk from 'lodash.chunk'
|
||||||
|
|
||||||
import {until} from '#/lib/async/until'
|
import {until} from '#/lib/async/until'
|
||||||
|
|
||||||
export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
export async function bulkWriteFollows(
|
||||||
|
agent: BskyAgent,
|
||||||
|
dids: string[],
|
||||||
|
via?: ComAtprotoRepoStrongRef.Main,
|
||||||
|
) {
|
||||||
const session = agent.session
|
const session = agent.session
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
@@ -22,6 +27,7 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
|
|||||||
$type: 'app.bsky.graph.follow',
|
$type: 'app.bsky.graph.follow',
|
||||||
subject: did,
|
subject: did,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
|
via,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -372,7 +372,10 @@ function Header({
|
|||||||
|
|
||||||
let followUris: Map<string, string>
|
let followUris: Map<string, string>
|
||||||
try {
|
try {
|
||||||
followUris = await bulkWriteFollows(agent, dids)
|
followUris = await bulkWriteFollows(agent, dids, {
|
||||||
|
uri: starterPack.uri,
|
||||||
|
cid: starterPack.cid,
|
||||||
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark')
|
Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark')
|
||||||
|
|||||||
Reference in New Issue
Block a user