···1+import {useMemo} from 'react'
2+3+import {useInterestsDisplayNames} from '#/lib/interests'
4+import {useActorSearch} from '#/state/queries/actor-search'
5+import {useGetSuggestedOnboardingUsersQuery} from '#/state/queries/trending/useGetSuggestedOnboardingUsersQuery'
6+7+/**
8+ * Conditional hook, used in case a user is a non-english speaker, in which
9+ * case we fall back to searching for users instead of our more curated set.
10+ */
11+export function useSuggestedOnboardingUsers({
12+ category = null,
13+ search = false,
14+ overrideInterests,
15+}: {
16+ category?: string | null
17+ /**
18+ * If true, we'll search for users using the translated value of `category`,
19+ * based on the user's app language setting
20+ */
21+ search?: boolean
22+ /**
23+ * In onboarding, interests haven't been saved to prefs yet, so we need to
24+ * pass them down through here
25+ */
26+ overrideInterests: string[]
27+}) {
28+ const interestsDisplayNames = useInterestsDisplayNames()
29+ const curated = useGetSuggestedOnboardingUsersQuery({
30+ enabled: !search,
31+ category,
32+ overrideInterests,
33+ })
34+ const searched = useActorSearch({
35+ enabled: !!search,
36+ // use user's app language translation for this value
37+ query: category ? interestsDisplayNames[category] : '',
38+ limit: 10,
39+ })
40+41+ return useMemo(() => {
42+ if (search) {
43+ return {
44+ // we're not paginating right now
45+ data: searched?.data
46+ ? {
47+ actors: searched.data.pages.flatMap(p => p.actors) ?? [],
48+ recId: undefined,
49+ }
50+ : undefined,
51+ isLoading: searched.isLoading,
52+ error: searched.error,
53+ isRefetching: searched.isRefetching,
54+ refetch: searched.refetch,
55+ }
56+ } else {
57+ return {
58+ data: curated.data,
59+ isLoading: curated.isLoading,
60+ error: curated.error,
61+ isRefetching: curated.isRefetching,
62+ refetch: curated.refetch,
63+ }
64+ }
65+ }, [curated, searched, search])
66+}
+1-8
src/screens/Search/util/useSuggestedUsers.ts
···11export function useSuggestedUsers({
12 category = null,
13 search = false,
14- overrideInterests,
15}: {
16 category?: string | null
17 /**
18 * If true, we'll search for users using the translated value of `category`,
19- * based on the user's "app language setting
20 */
21 search?: boolean
22- /**
23- * In onboarding, interests haven't been saved to prefs yet, so we need to
24- * pass them down through here
25- */
26- overrideInterests?: string[]
27}) {
28 const interestsDisplayNames = useInterestsDisplayNames()
29 const curated = useGetSuggestedUsersQuery({
30 enabled: !search,
31 category,
32- overrideInterests,
33 })
34 const searched = useActorSearch({
35 enabled: !!search,
···11export function useSuggestedUsers({
12 category = null,
13 search = false,
014}: {
15 category?: string | null
16 /**
17 * If true, we'll search for users using the translated value of `category`,
18+ * based on the user's app language setting
19 */
20 search?: boolean
0000021}) {
22 const interestsDisplayNames = useInterestsDisplayNames()
23 const curated = useGetSuggestedUsersQuery({
24 enabled: !search,
25 category,
026 })
27 const searched = useActorSearch({
28 enabled: !!search,
+2
src/state/cache/profile-shadow.ts
···25import {findAllProfilesInQueryData as findAllProfilesInProfileFollowersQueryData} from '#/state/queries/profile-followers'
26import {findAllProfilesInQueryData as findAllProfilesInProfileFollowsQueryData} from '#/state/queries/profile-follows'
27import {findAllProfilesInQueryData as findAllProfilesInSuggestedFollowsQueryData} from '#/state/queries/suggested-follows'
028import {findAllProfilesInQueryData as findAllProfilesInSuggestedUsersQueryData} from '#/state/queries/trending/useGetSuggestedUsersQuery'
29import {findAllProfilesInQueryData as findAllProfilesInPostThreadV2QueryData} from '#/state/queries/usePostThread/queryCache'
30import type * as bsky from '#/types/bsky'
···247 yield* findAllProfilesInProfileQueryData(queryClient, did)
248 yield* findAllProfilesInProfileFollowersQueryData(queryClient, did)
249 yield* findAllProfilesInProfileFollowsQueryData(queryClient, did)
0250 yield* findAllProfilesInSuggestedUsersQueryData(queryClient, did)
251 yield* findAllProfilesInSuggestedFollowsQueryData(queryClient, did)
252 yield* findAllProfilesInActorSearchQueryData(queryClient, did)
···25import {findAllProfilesInQueryData as findAllProfilesInProfileFollowersQueryData} from '#/state/queries/profile-followers'
26import {findAllProfilesInQueryData as findAllProfilesInProfileFollowsQueryData} from '#/state/queries/profile-follows'
27import {findAllProfilesInQueryData as findAllProfilesInSuggestedFollowsQueryData} from '#/state/queries/suggested-follows'
28+import {findAllProfilesInQueryData as findAllProfilesInSuggestedOnboardingUsersQueryData} from '#/state/queries/trending/useGetSuggestedOnboardingUsersQuery'
29import {findAllProfilesInQueryData as findAllProfilesInSuggestedUsersQueryData} from '#/state/queries/trending/useGetSuggestedUsersQuery'
30import {findAllProfilesInQueryData as findAllProfilesInPostThreadV2QueryData} from '#/state/queries/usePostThread/queryCache'
31import type * as bsky from '#/types/bsky'
···248 yield* findAllProfilesInProfileQueryData(queryClient, did)
249 yield* findAllProfilesInProfileFollowersQueryData(queryClient, did)
250 yield* findAllProfilesInProfileFollowsQueryData(queryClient, did)
251+ yield* findAllProfilesInSuggestedOnboardingUsersQueryData(queryClient, did)
252 yield* findAllProfilesInSuggestedUsersQueryData(queryClient, did)
253 yield* findAllProfilesInSuggestedFollowsQueryData(queryClient, did)
254 yield* findAllProfilesInActorSearchQueryData(queryClient, did)