f7a2368100
* grow banner when overscrolling * add blurview * make backdrop blur as it scrolls * add activity indicator * use rotated spinner instead of arrow * persist position of back button * make back button prettier * make blur less jarring * Unify effects * Tweak impl * determine if should animate based on scroll amount * sign comment --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import {AppBskyGraphGetLists, moderateUserList} from '@atproto/api'
|
|
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
|
|
|
import {useAgent} from '#/state/session'
|
|
import {useModerationOpts} from '../preferences/moderation-opts'
|
|
|
|
const PAGE_SIZE = 30
|
|
type RQPageParam = string | undefined
|
|
|
|
export const RQKEY_ROOT = 'profile-lists'
|
|
export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
|
|
|
export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
|
|
const moderationOpts = useModerationOpts()
|
|
const enabled = opts?.enabled !== false && Boolean(moderationOpts)
|
|
const agent = useAgent()
|
|
return useInfiniteQuery<
|
|
AppBskyGraphGetLists.OutputSchema,
|
|
Error,
|
|
InfiniteData<AppBskyGraphGetLists.OutputSchema>,
|
|
QueryKey,
|
|
RQPageParam
|
|
>({
|
|
queryKey: RQKEY(did),
|
|
async queryFn({pageParam}: {pageParam: RQPageParam}) {
|
|
const res = await agent.app.bsky.graph.getLists({
|
|
actor: did,
|
|
limit: PAGE_SIZE,
|
|
cursor: pageParam,
|
|
})
|
|
|
|
return res.data
|
|
},
|
|
initialPageParam: undefined,
|
|
getNextPageParam: lastPage => lastPage.cursor,
|
|
enabled,
|
|
select(data) {
|
|
return {
|
|
...data,
|
|
pages: data.pages.map(page => {
|
|
return {
|
|
...page,
|
|
lists: page.lists.filter(list => {
|
|
const decision = moderateUserList(list, moderationOpts!)
|
|
return !decision.ui('contentList').filter
|
|
}),
|
|
}
|
|
}),
|
|
}
|
|
},
|
|
})
|
|
}
|