Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041import {useCallback} from 'react'import {useQueryClient} from '@tanstack/react-query'
import {logger} from '#/logger'import {updateProfileShadow} from '#/state/cache/profile-shadow'import {useAppviewClient} from '#/state/session'import {app} from '#/lexicons'import type * as bsky from '#/types/bsky'
/** * Fetches a fresh verification state from the app view and updates our profile * cache. This state is computed using a variety of factors on the server, so * we need to get this data from the server. */export function useUpdateProfileVerificationCache() { const qc = useQueryClient() const client = useAppviewClient()
return useCallback( async ({profile}: {profile: bsky.profile.AnyProfileView}) => { try { if (!profile.did) { logger.warn(`useUpdateProfileVerificationCache: no did`, {profile}) return } const updated = await client.call(app.bsky.actor.getProfile, { actor: profile.did, }) updateProfileShadow(qc, profile.did, { verification: updated.verification, }) } catch (e) { logger.error(`useUpdateProfileVerificationCache failed`, { safeMessage: e, }) } }, [client, qc], )}