Add feedgens tab to profile (#1889)

This commit is contained in:
Paul Frazee 2023-11-13 14:46:19 -08:00 committed by GitHub
parent b04748e703
commit 9fca7b3af6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 296 additions and 34 deletions

View file

@ -24,7 +24,7 @@ export function useProfileExtraInfoQuery(did: string) {
])
return {
hasLists: listsRes.data.lists.length > 0,
hasFeeds: feedsRes.data.feeds.length > 0,
hasFeedgens: feedsRes.data.feeds.length > 0,
}
},
})

View file

@ -0,0 +1,31 @@
import {AppBskyFeedGetActorFeeds} from '@atproto/api'
import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query'
import {useSession} from '../session'
const PAGE_SIZE = 30
type RQPageParam = string | undefined
export const RQKEY = (did: string) => ['profile-feedgens', did]
export function useProfileFeedgensQuery(did: string) {
const {agent} = useSession()
return useInfiniteQuery<
AppBskyFeedGetActorFeeds.OutputSchema,
Error,
InfiniteData<AppBskyFeedGetActorFeeds.OutputSchema>,
QueryKey,
RQPageParam
>({
queryKey: RQKEY(did),
async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.feed.getActorFeeds({
actor: did,
limit: PAGE_SIZE,
cursor: pageParam,
})
return res.data
},
initialPageParam: undefined,
getNextPageParam: lastPage => lastPage.cursor,
})
}