starter pack dialog flow from profileMenu
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
import {AppBskyGraphGetActorStarterPacks} from '@atproto/api'
|
||||
import {
|
||||
InfiniteData,
|
||||
QueryClient,
|
||||
QueryKey,
|
||||
type AppBskyGraphGetActorStarterPacks,
|
||||
type AppBskyGraphGetStarterPacksWithMembership,
|
||||
} from '@atproto/api'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
type QueryKey,
|
||||
useInfiniteQuery,
|
||||
} from '@tanstack/react-query'
|
||||
|
||||
import {useAgent} from '#/state/session'
|
||||
|
||||
export const RQKEY_ROOT = 'actor-starter-packs'
|
||||
export const RQKEY_WITH_MEMBERSHIP_ROOT = 'actor-starter-packs-with-membership'
|
||||
export const RQKEY = (did?: string) => [RQKEY_ROOT, did]
|
||||
export const RQKEY_WITH_MEMBERSHIP = (did?: string) => [
|
||||
RQKEY_WITH_MEMBERSHIP_ROOT,
|
||||
did,
|
||||
]
|
||||
|
||||
export function useActorStarterPacksQuery({
|
||||
did,
|
||||
@@ -42,6 +50,37 @@ export function useActorStarterPacksQuery({
|
||||
})
|
||||
}
|
||||
|
||||
export function useActorStarterPacksWithMembershipsQuery({
|
||||
did,
|
||||
enabled = true,
|
||||
}: {
|
||||
did?: string
|
||||
enabled?: boolean
|
||||
}) {
|
||||
const agent = useAgent()
|
||||
|
||||
return useInfiniteQuery<
|
||||
AppBskyGraphGetStarterPacksWithMembership.OutputSchema,
|
||||
Error,
|
||||
InfiniteData<AppBskyGraphGetStarterPacksWithMembership.OutputSchema>,
|
||||
QueryKey,
|
||||
string | undefined
|
||||
>({
|
||||
queryKey: RQKEY_WITH_MEMBERSHIP(did),
|
||||
queryFn: async ({pageParam}: {pageParam?: string}) => {
|
||||
const res = await agent.app.bsky.graph.getStarterPacksWithMembership({
|
||||
actor: did!,
|
||||
limit: 10,
|
||||
cursor: pageParam,
|
||||
})
|
||||
return res.data
|
||||
},
|
||||
enabled: Boolean(did) && enabled,
|
||||
initialPageParam: undefined,
|
||||
getNextPageParam: lastPage => lastPage.cursor,
|
||||
})
|
||||
}
|
||||
|
||||
export async function invalidateActorStarterPacksQuery({
|
||||
queryClient,
|
||||
did,
|
||||
|
||||
Reference in New Issue
Block a user