ensure selected interests are passed through to interests query

This commit is contained in:
Samuel Newman
2025-08-21 16:15:57 +03:00
parent ca4e469a61
commit 06b072a289
3 changed files with 16 additions and 1 deletions
@@ -74,6 +74,7 @@ export function StepSuggestedAccounts() {
} = useSuggestedUsers({ } = useSuggestedUsers({
category: selectedInterest || (useFullExperience ? null : interests[0]), category: selectedInterest || (useFullExperience ? null : interests[0]),
search: !useFullExperience, search: !useFullExperience,
overrideInterests: state.interestsStepResults.selectedInterests,
}) })
const isError = !!error const isError = !!error
@@ -11,6 +11,7 @@ import {useInterestsDisplayNames} from '#/screens/Onboarding/state'
export function useSuggestedUsers({ export function useSuggestedUsers({
category = null, category = null,
search = false, search = false,
overrideInterests,
}: { }: {
category?: string | null category?: string | null
/** /**
@@ -18,11 +19,17 @@ export function useSuggestedUsers({
* based on the user's "app language setting * based on the user's "app language setting
*/ */
search?: boolean 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 interestsDisplayNames = useInterestsDisplayNames()
const curated = useGetSuggestedUsersQuery({ const curated = useGetSuggestedUsersQuery({
enabled: !search, enabled: !search,
category, category,
overrideInterests,
}) })
const searched = useActorSearchPaginated({ const searched = useActorSearchPaginated({
enabled: !!search, enabled: !!search,
@@ -17,6 +17,7 @@ export type QueryProps = {
category?: string | null category?: string | null
limit?: number limit?: number
enabled?: boolean enabled?: boolean
overrideInterests?: string[]
} }
export const getSuggestedUsersQueryKeyRoot = 'unspecced-suggested-users' export const getSuggestedUsersQueryKeyRoot = 'unspecced-suggested-users'
@@ -24,6 +25,7 @@ export const createGetSuggestedUsersQueryKey = (props: QueryProps) => [
getSuggestedUsersQueryKeyRoot, getSuggestedUsersQueryKeyRoot,
props.category, props.category,
props.limit, props.limit,
props.overrideInterests?.join(','),
] ]
export function useGetSuggestedUsersQuery(props: QueryProps) { export function useGetSuggestedUsersQuery(props: QueryProps) {
@@ -36,6 +38,7 @@ export function useGetSuggestedUsersQuery(props: QueryProps) {
queryKey: createGetSuggestedUsersQueryKey(props), queryKey: createGetSuggestedUsersQueryKey(props),
queryFn: async () => { queryFn: async () => {
const contentLangs = getContentLanguages().join(',') const contentLangs = getContentLanguages().join(',')
const interests = aggregateUserInterests(preferences)
const {data} = await agent.app.bsky.unspecced.getSuggestedUsers( const {data} = await agent.app.bsky.unspecced.getSuggestedUsers(
{ {
category: props.category ?? undefined, category: props.category ?? undefined,
@@ -43,7 +46,11 @@ export function useGetSuggestedUsersQuery(props: QueryProps) {
}, },
{ {
headers: { headers: {
...createBskyTopicsHeader(aggregateUserInterests(preferences)), ...createBskyTopicsHeader(
props.overrideInterests && props.overrideInterests.length > 0
? props.overrideInterests.join(',')
: interests,
),
'Accept-Language': contentLangs, 'Accept-Language': contentLangs,
}, },
}, },