about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/screens/Onboarding/util.ts12
-rw-r--r--src/screens/StarterPack/StarterPackScreen.tsx14
2 files changed, 22 insertions, 4 deletions
diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts
index f3c800d05..b9ecc4b98 100644
--- a/src/screens/Onboarding/util.ts
+++ b/src/screens/Onboarding/util.ts
@@ -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(
diff --git a/src/screens/StarterPack/StarterPackScreen.tsx b/src/screens/StarterPack/StarterPackScreen.tsx
index bdf6f9dbe..7c5cfd0b7 100644
--- a/src/screens/StarterPack/StarterPackScreen.tsx
+++ b/src/screens/StarterPack/StarterPackScreen.tsx
@@ -23,14 +23,16 @@ import {
 import {cleanError} from '#/lib/strings/errors'
 import {logger} from '#/logger'
 import {useDeleteStarterPackMutation} from '#/state/queries/starter-packs'
+import {batchedUpdates} from 'lib/batchedUpdates'
 import {HITSLOP_20} from 'lib/constants'
 import {makeProfileLink, makeStarterPackLink} from 'lib/routes/links'
 import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types'
 import {logEvent} from 'lib/statsig/statsig'
 import {getStarterPackOgCard} from 'lib/strings/starter-pack'
 import {isWeb} from 'platform/detection'
+import {updateProfileShadow} from 'state/cache/profile-shadow'
 import {useModerationOpts} from 'state/preferences/moderation-opts'
-import {RQKEY, useListMembersQuery} from 'state/queries/list-members'
+import {useListMembersQuery} from 'state/queries/list-members'
 import {useResolveDidQuery} from 'state/queries/resolve-uri'
 import {useShortenLink} from 'state/queries/shorten-link'
 import {useStarterPackQuery} from 'state/queries/starter-packs'
@@ -275,10 +277,14 @@ function Header({
         .filter(li => !li.subject.viewer?.following)
         .map(li => li.subject.did)
 
-      await bulkWriteFollows(agent, dids)
+      const followUris = await bulkWriteFollows(agent, dids)
 
-      await queryClient.refetchQueries({
-        queryKey: RQKEY(starterPack.list.uri),
+      batchedUpdates(() => {
+        for (let did of dids) {
+          updateProfileShadow(queryClient, did, {
+            followingUri: followUris.get(did),
+          })
+        }
       })
 
       logEvent('starterPack:followAll', {