diff options
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/queries/profile-extra-info.ts | 2 | ||||
-rw-r--r-- | src/state/queries/profile-feedgens.ts | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/state/queries/profile-extra-info.ts b/src/state/queries/profile-extra-info.ts index 54b19c89a..6ba665086 100644 --- a/src/state/queries/profile-extra-info.ts +++ b/src/state/queries/profile-extra-info.ts @@ -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, } }, }) diff --git a/src/state/queries/profile-feedgens.ts b/src/state/queries/profile-feedgens.ts new file mode 100644 index 000000000..652a123d9 --- /dev/null +++ b/src/state/queries/profile-feedgens.ts @@ -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, + }) +} |