diff options
author | Eric Bailey <git@esb.lol> | 2024-04-29 16:04:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 22:04:35 +0100 |
commit | a4e34537cee8e12a022238f054bee4fe22cc7325 (patch) | |
tree | e8ffbb4993441f64e4c112e9b046c566e577d661 /src/state/queries/suggested-follows.ts | |
parent | d893fe005d9d43e28b2926f8fed4f13165843d3b (diff) | |
download | voidsky-a4e34537cee8e12a022238f054bee4fe22cc7325.tar.zst |
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>
Diffstat (limited to 'src/state/queries/suggested-follows.ts')
-rw-r--r-- | src/state/queries/suggested-follows.ts | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/state/queries/suggested-follows.ts b/src/state/queries/suggested-follows.ts index 936912ab3..3338130f4 100644 --- a/src/state/queries/suggested-follows.ts +++ b/src/state/queries/suggested-follows.ts @@ -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( |