Fetch more than 3 suggested follows after first load (#4595)

* Fetch more than 3 sugg follows after first load

* Preview handling via overfetching
This commit is contained in:
Eric Bailey 2024-06-21 14:50:49 -05:00 committed by GitHub
parent 55812b0394
commit cb37647949
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 8 deletions

View file

@ -34,13 +34,14 @@ const suggestedFollowsByActorQueryKey = (did: string) => [
did,
]
type SuggestedFollowsOptions = {limit?: number}
type SuggestedFollowsOptions = {limit?: number; subsequentPageLimit?: number}
export function useSuggestedFollowsQuery(options?: SuggestedFollowsOptions) {
const {currentAccount} = useSession()
const agent = useAgent()
const moderationOpts = useModerationOpts()
const {data: preferences} = usePreferencesQuery()
const limit = options?.limit || 25
return useInfiniteQuery<
AppBskyActorGetSuggestions.OutputSchema,
@ -54,9 +55,13 @@ export function useSuggestedFollowsQuery(options?: SuggestedFollowsOptions) {
queryKey: suggestedFollowsQueryKey(options),
queryFn: async ({pageParam}) => {
const contentLangs = getContentLanguages().join(',')
const maybeDifferentLimit =
options?.subsequentPageLimit && pageParam
? options.subsequentPageLimit
: limit
const res = await agent.app.bsky.actor.getSuggestions(
{
limit: options?.limit || 25,
limit: maybeDifferentLimit,
cursor: pageParam,
},
{