Revert "[ALG-96] Don't fall back to search for onboarding user suggestions (#10680)"
This reverts commit 59765138ce.
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
import {useCallback, useEffect, useRef, useState} from 'react'
|
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ModerationOpts} from '@atproto/api'
|
import {type ModerationOpts} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||||
|
import * as bcp47Match from 'bcp-47-match'
|
||||||
|
|
||||||
import {wait} from '#/lib/async/wait'
|
import {wait} from '#/lib/async/wait'
|
||||||
import {popularInterests, useInterestsDisplayNames} from '#/lib/interests'
|
import {popularInterests, useInterestsDisplayNames} from '#/lib/interests'
|
||||||
import {isBlockedOrBlocking, isMuted} from '#/lib/moderation/blocked-and-muted'
|
import {isBlockedOrBlocking, isMuted} from '#/lib/moderation/blocked-and-muted'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {updateProfileShadow} from '#/state/cache/profile-shadow'
|
import {updateProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
|
import {useLanguagePrefs} from '#/state/preferences'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {
|
import {
|
||||||
@@ -51,6 +53,19 @@ export function StepSuggestedAccounts() {
|
|||||||
// so we can enable/disable the button without having to dig through the shadow cache
|
// so we can enable/disable the button without having to dig through the shadow cache
|
||||||
const [followedUsers, setFollowedUsers] = useState<string[]>([])
|
const [followedUsers, setFollowedUsers] = useState<string[]>([])
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special language handling copied wholesale from the Explore screen
|
||||||
|
*/
|
||||||
|
const {contentLanguages} = useLanguagePrefs()
|
||||||
|
const useFullExperience = useMemo(() => {
|
||||||
|
if (contentLanguages.length === 0) return true
|
||||||
|
return bcp47Match.basicFilter('en', contentLanguages).length > 0
|
||||||
|
}, [contentLanguages])
|
||||||
|
const interestsDisplayNames = useInterestsDisplayNames()
|
||||||
|
const interests = Object.keys(interestsDisplayNames)
|
||||||
|
.sort(boostInterests(popularInterests))
|
||||||
|
.sort(boostInterests(state.interestsStepResults.selectedInterests))
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: suggestedUsers,
|
data: suggestedUsers,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -58,8 +73,8 @@ export function StepSuggestedAccounts() {
|
|||||||
isRefetching,
|
isRefetching,
|
||||||
refetch,
|
refetch,
|
||||||
} = useSuggestedOnboardingUsers({
|
} = useSuggestedOnboardingUsers({
|
||||||
category: selectedInterest,
|
category: selectedInterest || (useFullExperience ? null : interests[0]),
|
||||||
search: false,
|
search: !useFullExperience,
|
||||||
overrideInterests: state.interestsStepResults.selectedInterests,
|
overrideInterests: state.interestsStepResults.selectedInterests,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -90,6 +105,7 @@ export function StepSuggestedAccounts() {
|
|||||||
ax.metric('suggestedUser:follow', {
|
ax.metric('suggestedUser:follow', {
|
||||||
logContext: 'Onboarding',
|
logContext: 'Onboarding',
|
||||||
location: 'FollowAll',
|
location: 'FollowAll',
|
||||||
|
recSource: !useFullExperience ? 'Search' : undefined,
|
||||||
recId: suggestedUsers?.recId,
|
recId: suggestedUsers?.recId,
|
||||||
position: i,
|
position: i,
|
||||||
suggestedDid: did,
|
suggestedDid: did,
|
||||||
@@ -140,6 +156,7 @@ export function StepSuggestedAccounts() {
|
|||||||
seenProfilesRef.current.add(did)
|
seenProfilesRef.current.add(did)
|
||||||
ax.metric('suggestedUser:seen', {
|
ax.metric('suggestedUser:seen', {
|
||||||
logContext: 'Onboarding',
|
logContext: 'Onboarding',
|
||||||
|
recSource: !useFullExperience ? 'Search' : undefined,
|
||||||
recId: suggestedUsers?.recId,
|
recId: suggestedUsers?.recId,
|
||||||
position,
|
position,
|
||||||
suggestedDid: did,
|
suggestedDid: did,
|
||||||
@@ -147,7 +164,7 @@ export function StepSuggestedAccounts() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[ax, selectedInterest, suggestedUsers?.recId],
|
[ax, selectedInterest, suggestedUsers?.recId, useFullExperience],
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -233,6 +250,7 @@ export function StepSuggestedAccounts() {
|
|||||||
position={index}
|
position={index}
|
||||||
category={selectedInterest}
|
category={selectedInterest}
|
||||||
onSeen={onProfileSeen}
|
onSeen={onProfileSeen}
|
||||||
|
recSource={!useFullExperience ? 'Search' : undefined}
|
||||||
recId={suggestedUsers.recId}
|
recId={suggestedUsers.recId}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user