Add feedgens tab to profile (#1889)
This commit is contained in:
parent
b04748e703
commit
9fca7b3af6
5 changed files with 296 additions and 34 deletions
|
@ -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,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
31
src/state/queries/profile-feedgens.ts
Normal file
31
src/state/queries/profile-feedgens.ts
Normal 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,
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue