migrate the pinned post and verification cache profile reads to the appview client

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-03 15:17:27 +03:00
parent d8d4b3cf32
commit 384058d6a2
2 changed files with 13 additions and 9 deletions
+6 -4
View File
@@ -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) {
@@ -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],
)
}