ensure selected interests are passed through to interests query
This commit is contained in:
@@ -74,6 +74,7 @@ export function StepSuggestedAccounts() {
|
||||
} = useSuggestedUsers({
|
||||
category: selectedInterest || (useFullExperience ? null : interests[0]),
|
||||
search: !useFullExperience,
|
||||
overrideInterests: state.interestsStepResults.selectedInterests,
|
||||
})
|
||||
|
||||
const isError = !!error
|
||||
|
||||
@@ -11,6 +11,7 @@ import {useInterestsDisplayNames} from '#/screens/Onboarding/state'
|
||||
export function useSuggestedUsers({
|
||||
category = null,
|
||||
search = false,
|
||||
overrideInterests,
|
||||
}: {
|
||||
category?: string | null
|
||||
/**
|
||||
@@ -18,11 +19,17 @@ export function useSuggestedUsers({
|
||||
* based on the user's "app language setting
|
||||
*/
|
||||
search?: boolean
|
||||
/**
|
||||
* In onboarding, interests haven't been saved to prefs yet, so we need to
|
||||
* pass them down through here
|
||||
*/
|
||||
overrideInterests?: string[]
|
||||
}) {
|
||||
const interestsDisplayNames = useInterestsDisplayNames()
|
||||
const curated = useGetSuggestedUsersQuery({
|
||||
enabled: !search,
|
||||
category,
|
||||
overrideInterests,
|
||||
})
|
||||
const searched = useActorSearchPaginated({
|
||||
enabled: !!search,
|
||||
|
||||
@@ -17,6 +17,7 @@ export type QueryProps = {
|
||||
category?: string | null
|
||||
limit?: number
|
||||
enabled?: boolean
|
||||
overrideInterests?: string[]
|
||||
}
|
||||
|
||||
export const getSuggestedUsersQueryKeyRoot = 'unspecced-suggested-users'
|
||||
@@ -24,6 +25,7 @@ export const createGetSuggestedUsersQueryKey = (props: QueryProps) => [
|
||||
getSuggestedUsersQueryKeyRoot,
|
||||
props.category,
|
||||
props.limit,
|
||||
props.overrideInterests?.join(','),
|
||||
]
|
||||
|
||||
export function useGetSuggestedUsersQuery(props: QueryProps) {
|
||||
@@ -36,6 +38,7 @@ export function useGetSuggestedUsersQuery(props: QueryProps) {
|
||||
queryKey: createGetSuggestedUsersQueryKey(props),
|
||||
queryFn: async () => {
|
||||
const contentLangs = getContentLanguages().join(',')
|
||||
const interests = aggregateUserInterests(preferences)
|
||||
const {data} = await agent.app.bsky.unspecced.getSuggestedUsers(
|
||||
{
|
||||
category: props.category ?? undefined,
|
||||
@@ -43,7 +46,11 @@ export function useGetSuggestedUsersQuery(props: QueryProps) {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
...createBskyTopicsHeader(aggregateUserInterests(preferences)),
|
||||
...createBskyTopicsHeader(
|
||||
props.overrideInterests && props.overrideInterests.length > 0
|
||||
? props.overrideInterests.join(',')
|
||||
: interests,
|
||||
),
|
||||
'Accept-Language': contentLangs,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user