···11+import {useMemo} from 'react'
22+33+import {useInterestsDisplayNames} from '#/lib/interests'
44+import {useActorSearch} from '#/state/queries/actor-search'
55+import {useGetSuggestedOnboardingUsersQuery} from '#/state/queries/trending/useGetSuggestedOnboardingUsersQuery'
66+77+/**
88+ * Conditional hook, used in case a user is a non-english speaker, in which
99+ * case we fall back to searching for users instead of our more curated set.
1010+ */
1111+export function useSuggestedOnboardingUsers({
1212+ category = null,
1313+ search = false,
1414+ overrideInterests,
1515+}: {
1616+ category?: string | null
1717+ /**
1818+ * If true, we'll search for users using the translated value of `category`,
1919+ * based on the user's app language setting
2020+ */
2121+ search?: boolean
2222+ /**
2323+ * In onboarding, interests haven't been saved to prefs yet, so we need to
2424+ * pass them down through here
2525+ */
2626+ overrideInterests: string[]
2727+}) {
2828+ const interestsDisplayNames = useInterestsDisplayNames()
2929+ const curated = useGetSuggestedOnboardingUsersQuery({
3030+ enabled: !search,
3131+ category,
3232+ overrideInterests,
3333+ })
3434+ const searched = useActorSearch({
3535+ enabled: !!search,
3636+ // use user's app language translation for this value
3737+ query: category ? interestsDisplayNames[category] : '',
3838+ limit: 10,
3939+ })
4040+4141+ return useMemo(() => {
4242+ if (search) {
4343+ return {
4444+ // we're not paginating right now
4545+ data: searched?.data
4646+ ? {
4747+ actors: searched.data.pages.flatMap(p => p.actors) ?? [],
4848+ recId: undefined,
4949+ }
5050+ : undefined,
5151+ isLoading: searched.isLoading,
5252+ error: searched.error,
5353+ isRefetching: searched.isRefetching,
5454+ refetch: searched.refetch,
5555+ }
5656+ } else {
5757+ return {
5858+ data: curated.data,
5959+ isLoading: curated.isLoading,
6060+ error: curated.error,
6161+ isRefetching: curated.isRefetching,
6262+ refetch: curated.refetch,
6363+ }
6464+ }
6565+ }, [curated, searched, search])
6666+}
+1-8
src/screens/Search/util/useSuggestedUsers.ts
···1111export function useSuggestedUsers({
1212 category = null,
1313 search = false,
1414- overrideInterests,
1514}: {
1615 category?: string | null
1716 /**
1817 * If true, we'll search for users using the translated value of `category`,
1919- * based on the user's "app language setting
1818+ * based on the user's app language setting
2019 */
2120 search?: boolean
2222- /**
2323- * In onboarding, interests haven't been saved to prefs yet, so we need to
2424- * pass them down through here
2525- */
2626- overrideInterests?: string[]
2721}) {
2822 const interestsDisplayNames = useInterestsDisplayNames()
2923 const curated = useGetSuggestedUsersQuery({
3024 enabled: !search,
3125 category,
3232- overrideInterests,
3326 })
3427 const searched = useActorSearch({
3528 enabled: !!search,
+2
src/state/cache/profile-shadow.ts
···2525import {findAllProfilesInQueryData as findAllProfilesInProfileFollowersQueryData} from '#/state/queries/profile-followers'
2626import {findAllProfilesInQueryData as findAllProfilesInProfileFollowsQueryData} from '#/state/queries/profile-follows'
2727import {findAllProfilesInQueryData as findAllProfilesInSuggestedFollowsQueryData} from '#/state/queries/suggested-follows'
2828+import {findAllProfilesInQueryData as findAllProfilesInSuggestedOnboardingUsersQueryData} from '#/state/queries/trending/useGetSuggestedOnboardingUsersQuery'
2829import {findAllProfilesInQueryData as findAllProfilesInSuggestedUsersQueryData} from '#/state/queries/trending/useGetSuggestedUsersQuery'
2930import {findAllProfilesInQueryData as findAllProfilesInPostThreadV2QueryData} from '#/state/queries/usePostThread/queryCache'
3031import type * as bsky from '#/types/bsky'
···247248 yield* findAllProfilesInProfileQueryData(queryClient, did)
248249 yield* findAllProfilesInProfileFollowersQueryData(queryClient, did)
249250 yield* findAllProfilesInProfileFollowsQueryData(queryClient, did)
251251+ yield* findAllProfilesInSuggestedOnboardingUsersQueryData(queryClient, did)
250252 yield* findAllProfilesInSuggestedUsersQueryData(queryClient, did)
251253 yield* findAllProfilesInSuggestedFollowsQueryData(queryClient, did)
252254 yield* findAllProfilesInActorSearchQueryData(queryClient, did)