Send Bluesky feeds and suggested follows more data (#3695)
* WIP * Fix constructors * Clean up * Tweak * Rm extra assignment * Narrow down the argument --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
@@ -12,8 +12,16 @@ import {
|
||||
useQuery,
|
||||
} from '@tanstack/react-query'
|
||||
|
||||
import {
|
||||
aggregateUserInterests,
|
||||
createBskyTopicsHeader,
|
||||
} from '#/lib/api/feed/utils'
|
||||
import {getContentLanguages} from '#/state/preferences/languages'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {useModerationOpts} from '#/state/queries/preferences'
|
||||
import {
|
||||
useModerationOpts,
|
||||
usePreferencesQuery,
|
||||
} from '#/state/queries/preferences'
|
||||
import {useAgent, useSession} from '#/state/session'
|
||||
|
||||
const suggestedFollowsQueryKeyRoot = 'suggested-follows'
|
||||
@@ -29,6 +37,7 @@ export function useSuggestedFollowsQuery() {
|
||||
const {currentAccount} = useSession()
|
||||
const {getAgent} = useAgent()
|
||||
const moderationOpts = useModerationOpts()
|
||||
const {data: preferences} = usePreferencesQuery()
|
||||
|
||||
return useInfiniteQuery<
|
||||
AppBskyActorGetSuggestions.OutputSchema,
|
||||
@@ -37,14 +46,23 @@ export function useSuggestedFollowsQuery() {
|
||||
QueryKey,
|
||||
string | undefined
|
||||
>({
|
||||
enabled: !!moderationOpts,
|
||||
enabled: !!moderationOpts && !!preferences,
|
||||
staleTime: STALE.HOURS.ONE,
|
||||
queryKey: suggestedFollowsQueryKey,
|
||||
queryFn: async ({pageParam}) => {
|
||||
const res = await getAgent().app.bsky.actor.getSuggestions({
|
||||
limit: 25,
|
||||
cursor: pageParam,
|
||||
})
|
||||
const contentLangs = getContentLanguages().join(',')
|
||||
const res = await getAgent().app.bsky.actor.getSuggestions(
|
||||
{
|
||||
limit: 25,
|
||||
cursor: pageParam,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
...createBskyTopicsHeader(aggregateUserInterests(preferences)),
|
||||
'Accept-Language': contentLangs,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
res.data.actors = res.data.actors
|
||||
.filter(
|
||||
|
||||
Reference in New Issue
Block a user