diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-13 14:46:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 14:46:19 -0800 |
commit | 9fca7b3af6114d28e13f475395c8911c55b33cb1 (patch) | |
tree | 1cf22e7dfe3d4778d8eaf62b66c6d8ba3ef8c227 /src/state/queries | |
parent | b04748e703cede419a027f6bbb3c8180ed10eb1f (diff) | |
download | voidsky-9fca7b3af6114d28e13f475395c8911c55b33cb1.tar.zst |
Add feedgens tab to profile (#1889)
Diffstat (limited to 'src/state/queries')
-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, + }) +} |