diff options
Diffstat (limited to 'src/state/queries/profile-extra-info.ts')
-rw-r--r-- | src/state/queries/profile-extra-info.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/state/queries/profile-extra-info.ts b/src/state/queries/profile-extra-info.ts new file mode 100644 index 000000000..54b19c89a --- /dev/null +++ b/src/state/queries/profile-extra-info.ts @@ -0,0 +1,31 @@ +import {useQuery} from '@tanstack/react-query' +import {useSession} from '../session' + +export const RQKEY = (did: string) => ['profile-extra-info', did] + +/** + * Fetches some additional information for the profile screen which + * is not available in the API's ProfileView + */ +export function useProfileExtraInfoQuery(did: string) { + const {agent} = useSession() + return useQuery({ + queryKey: RQKEY(did), + async queryFn() { + const [listsRes, feedsRes] = await Promise.all([ + agent.app.bsky.graph.getLists({ + actor: did, + limit: 1, + }), + agent.app.bsky.feed.getActorFeeds({ + actor: did, + limit: 1, + }), + ]) + return { + hasLists: listsRes.data.lists.length > 0, + hasFeeds: feedsRes.data.feeds.length > 0, + } + }, + }) +} |