From 384058d6a2f7f501517baefbbd58ddaf8cc3b12f Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 3 Aug 2026 15:17:27 +0300 Subject: [PATCH] migrate the pinned post and verification cache profile reads to the appview client Co-Authored-By: Claude Fable 5 --- src/state/queries/pinned-post.ts | 10 ++++++---- .../useUpdateProfileVerificationCache.ts | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/state/queries/pinned-post.ts b/src/state/queries/pinned-post.ts index 09a0b4c9b9..c2d6373f78 100644 --- a/src/state/queries/pinned-post.ts +++ b/src/state/queries/pinned-post.ts @@ -5,14 +5,15 @@ import {useMutation, useQueryClient} from '@tanstack/react-query' import {logger} from '#/logger' import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed' import * as Toast from '#/components/Toast' +import {app} from '#/lexicons' import {updatePostShadow} from '../cache/post-shadow' -import {useAgent, useSession} from '../session' +import {useAppviewClient, useSession} from '../session' import {useProfileUpdateMutation} from './profile' export function usePinnedPostMutation() { const {_} = useLingui() const {currentAccount} = useSession() - const agent = useAgent() + const client = useAppviewClient() const queryClient = useQueryClient() const {mutateAsync: profileUpdateMutate} = useProfileUpdateMutation() @@ -33,8 +34,9 @@ export function usePinnedPostMutation() { // get the currently pinned post so we can optimistically remove the pin from it if (!currentAccount) throw new Error('Not signed in') - const {data: profile} = await agent.getProfile({ - actor: currentAccount.did, + const profile = await client.call(app.bsky.actor.getProfile, { + actor: + currentAccount.did as app.bsky.actor.getProfile.$Params['actor'], }) prevPinnedPost = profile.pinnedPost?.uri if (prevPinnedPost && prevPinnedPost !== postUri) { diff --git a/src/state/queries/verification/useUpdateProfileVerificationCache.ts b/src/state/queries/verification/useUpdateProfileVerificationCache.ts index f5ccf1458b..50b807209c 100644 --- a/src/state/queries/verification/useUpdateProfileVerificationCache.ts +++ b/src/state/queries/verification/useUpdateProfileVerificationCache.ts @@ -3,7 +3,8 @@ import {useQueryClient} from '@tanstack/react-query' import {logger} from '#/logger' import {updateProfileShadow} from '#/state/cache/profile-shadow' -import {useAgent} from '#/state/session' +import {useAppviewClient} from '#/state/session' +import {app} from '#/lexicons' import type * as bsky from '#/types/bsky' /** @@ -13,13 +14,14 @@ import type * as bsky from '#/types/bsky' */ export function useUpdateProfileVerificationCache() { const qc = useQueryClient() - const agent = useAgent() + const client = useAppviewClient() return useCallback( async ({profile}: {profile: bsky.profile.AnyProfileView}) => { try { - const {data: updated} = await agent.getProfile({ - actor: profile.did ?? '', + const updated = await client.call(app.bsky.actor.getProfile, { + actor: (profile.did ?? + '') as app.bsky.actor.getProfile.$Params['actor'], }) updateProfileShadow(qc, profile.did, { verification: updated.verification, @@ -30,6 +32,6 @@ export function useUpdateProfileVerificationCache() { }) } }, - [agent, qc], + [client, qc], ) }