migrate the starter pack writes to the pds client

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-03 23:41:15 +03:00
parent a86590ad4b
commit 3a970a7104
10 changed files with 216 additions and 192 deletions
@@ -21,7 +21,7 @@ import {
optimisticRemoveMatch,
useMatchesPassthroughQuery,
} from '#/state/queries/find-contacts'
import {useAgent, useAppviewClient, useSession} from '#/state/session'
import {useAppviewClient, usePdsClient, useSession} from '#/state/session'
import {List, type ListMethods} from '#/view/com/util/List'
import {UserAvatar} from '#/view/com/util/UserAvatar'
import {OnboardingPosition} from '#/screens/Onboarding/Layout'
@@ -91,7 +91,7 @@ export function ViewMatches({
const gutter = useGutters([0, 'wide'])
const moderationOpts = useModerationOpts()
const queryClient = useQueryClient()
const agent = useAgent()
const pdsClient = usePdsClient()
const client = useAppviewClient()
const insets = useSafeAreaInsets()
const listRef = useRef<ListMethods>(null)
@@ -127,7 +127,10 @@ export function ViewMatches({
})
}
const uris = await wait(500, bulkWriteFollows(agent, followableDids))
const uris = await wait(
500,
bulkWriteFollows(pdsClient, client, followableDids),
)
for (const did of followableDids) {
const uri = uris.get(did)
@@ -1,13 +1,14 @@
import {View} from 'react-native'
import {
type $Typed,
type AppBskyGraphDefs,
type AppBskyGraphListitem,
type AppBskyGraphStarterpack,
AtUri,
type ComAtprotoRepoApplyWrites,
} from '@atproto/api'
import {type AppBskyGraphDefs, type AppBskyGraphStarterpack} from '@atproto/api'
import {TID} from '@atproto/common-web'
import {type $Typed} from '@atproto/lex'
import {
type AtIdentifierString,
AtUri,
type AtUriString,
type DidString,
toDatetimeString,
} from '@atproto/syntax'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
@@ -20,7 +21,7 @@ import {wait} from '#/lib/async/wait'
import {type NavigationProp} from '#/lib/routes/types'
import {logger} from '#/logger'
import {getAllListMembers} from '#/state/queries/list-members'
import {useAgent, useAppviewClient, useSession} from '#/state/session'
import {useAppviewClient, usePdsClient, useSession} from '#/state/session'
import {atoms as a, platform, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {Button, ButtonText} from '#/components/Button'
@@ -29,6 +30,7 @@ import {Loader} from '#/components/Loader'
import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography'
import {useAnalytics} from '#/analytics'
import {app, com} from '#/lexicons'
import {CreateOrEditListDialog} from './CreateOrEditListDialog'
export function CreateListFromStarterPackDialog({
@@ -40,8 +42,8 @@ export function CreateListFromStarterPackDialog({
}) {
const {_} = useLingui()
const t = useTheme()
const agent = useAgent()
const appviewClient = useAppviewClient()
const pdsClient = usePdsClient()
const ax = useAnalytics()
const {currentAccount} = useSession()
const navigation = useNavigation<NavigationProp>()
@@ -80,13 +82,14 @@ export function CreateListFromStarterPackDialog({
)
if (items.length > 0) {
const listitemWrites: $Typed<ComAtprotoRepoApplyWrites.Create>[] =
const listitemWrites: $Typed<com.atproto.repo.applyWrites.Create>[] =
items.map(item => {
const listitemRecord: $Typed<AppBskyGraphListitem.Record> = {
const listitemRecord: $Typed<app.bsky.graph.listitem.Main> = {
$type: 'app.bsky.graph.listitem',
subject: item.subject.did,
list: listUri,
createdAt: new Date().toISOString(),
// the list view is still legacy-typed, so its strings are unbranded
subject: item.subject.did as DidString,
list: listUri as AtUriString,
createdAt: toDatetimeString(new Date()),
}
return {
$type: 'com.atproto.repo.applyWrites#create',
@@ -98,8 +101,8 @@ export function CreateListFromStarterPackDialog({
const chunks = chunk(listitemWrites, 50)
for (const c of chunks) {
await agent.com.atproto.repo.applyWrites({
repo: currentAccount.did,
await pdsClient.call(com.atproto.repo.applyWrites, {
repo: currentAccount.did as AtIdentifierString,
writes: c,
})
}
@@ -107,10 +110,10 @@ export function CreateListFromStarterPackDialog({
await until(
5,
1e3,
(res: {data: {items: unknown[]}}) => res.data.items.length > 0,
(res: {items: unknown[]}) => res.items.length > 0,
() =>
agent.app.bsky.graph.getList({
list: listUri,
appviewClient.call(app.bsky.graph.getList, {
list: listUri as AtUriString,
limit: 1,
}),
)