diff options
Diffstat (limited to 'src/screens/StarterPack/StarterPackScreen.tsx')
-rw-r--r-- | src/screens/StarterPack/StarterPackScreen.tsx | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/src/screens/StarterPack/StarterPackScreen.tsx b/src/screens/StarterPack/StarterPackScreen.tsx index 595e18527..5b267ff27 100644 --- a/src/screens/StarterPack/StarterPackScreen.tsx +++ b/src/screens/StarterPack/StarterPackScreen.tsx @@ -32,6 +32,7 @@ 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 {getAllListMembers} from 'state/queries/list-members' import {useResolvedStarterPackShortLink} from 'state/queries/resolve-short-link' import {useResolveDidQuery} from 'state/queries/resolve-uri' import {useShortenLink} from 'state/queries/shorten-link' @@ -327,42 +328,52 @@ function Header({ setIsProcessing(true) + let listItems: AppBskyGraphDefs.ListItemView[] = [] try { - const list = await agent.app.bsky.graph.getList({ - list: starterPack.list.uri, - }) - const dids = list.data.items - .filter( - li => - li.subject.did !== currentAccount?.did && - !isBlockedOrBlocking(li.subject) && - !isMuted(li.subject) && - !li.subject.viewer?.following, - ) - .map(li => li.subject.did) - - const followUris = await bulkWriteFollows(agent, dids) - - batchedUpdates(() => { - for (let did of dids) { - updateProfileShadow(queryClient, did, { - followingUri: followUris.get(did), - }) - } + listItems = await getAllListMembers(agent, starterPack.list.uri) + } catch (e) { + setIsProcessing(false) + Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark') + logger.error('Failed to get list members for starter pack', { + safeMessage: e, }) + return + } - logEvent('starterPack:followAll', { - logContext: 'StarterPackProfilesList', - starterPack: starterPack.uri, - count: dids.length, - }) - captureAction(ProgressGuideAction.Follow, dids.length) - Toast.show(_(msg`All accounts have been followed!`)) + const dids = listItems + .filter( + li => + li.subject.did !== currentAccount?.did && + !isBlockedOrBlocking(li.subject) && + !isMuted(li.subject) && + !li.subject.viewer?.following, + ) + .map(li => li.subject.did) + + let followUris: Map<string, string> + try { + followUris = await bulkWriteFollows(agent, dids) } catch (e) { - Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark') - } finally { setIsProcessing(false) + Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark') + logger.error('Failed to follow all accounts', {safeMessage: e}) } + + setIsProcessing(false) + batchedUpdates(() => { + for (let did of dids) { + updateProfileShadow(queryClient, did, { + followingUri: followUris.get(did), + }) + } + }) + Toast.show(_(msg`All accounts have been followed!`)) + captureAction(ProgressGuideAction.Follow, dids.length) + logEvent('starterPack:followAll', { + logContext: 'StarterPackProfilesList', + starterPack: starterPack.uri, + count: dids.length, + }) } if (!AppBskyGraphStarterpack.isRecord(record)) { |