[ALG-77] include 'for you' in see more suggested users (#10241)
This commit is contained in:
@@ -109,21 +109,32 @@ export function FollowDialogWithoutGuide({
|
|||||||
let lastSelectedInterest = ''
|
let lastSelectedInterest = ''
|
||||||
let lastSearchText = ''
|
let lastSearchText = ''
|
||||||
|
|
||||||
|
const FOR_YOU_TAB = 'all'
|
||||||
|
|
||||||
function DialogInner({guide}: {guide?: Follow10ProgressGuide}) {
|
function DialogInner({guide}: {guide?: Follow10ProgressGuide}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const interestsDisplayNames = useInterestsDisplayNames()
|
const rawInterestsDisplayNames = useInterestsDisplayNames()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const personalizedInterests = preferences?.interests?.tags
|
const personalizedInterests = preferences?.interests?.tags
|
||||||
const interests = Object.keys(interestsDisplayNames)
|
const interests = useMemo(
|
||||||
|
() => [
|
||||||
|
FOR_YOU_TAB,
|
||||||
|
...Object.keys(rawInterestsDisplayNames)
|
||||||
.sort(boostInterests(popularInterests))
|
.sort(boostInterests(popularInterests))
|
||||||
.sort(boostInterests(personalizedInterests))
|
.sort(boostInterests(personalizedInterests)),
|
||||||
|
],
|
||||||
|
[rawInterestsDisplayNames, personalizedInterests],
|
||||||
|
)
|
||||||
|
const interestsDisplayNames = useMemo(
|
||||||
|
() => ({
|
||||||
|
[FOR_YOU_TAB]: l`For You`,
|
||||||
|
...rawInterestsDisplayNames,
|
||||||
|
}),
|
||||||
|
[l, rawInterestsDisplayNames],
|
||||||
|
)
|
||||||
const [selectedInterest, setSelectedInterest] = useState(
|
const [selectedInterest, setSelectedInterest] = useState(
|
||||||
() =>
|
() => lastSelectedInterest || FOR_YOU_TAB,
|
||||||
lastSelectedInterest ||
|
|
||||||
(personalizedInterests && interests.includes(personalizedInterests[0])
|
|
||||||
? personalizedInterests[0]
|
|
||||||
: interests[0]),
|
|
||||||
)
|
)
|
||||||
const [searchText, setSearchText] = useState(lastSearchText)
|
const [searchText, setSearchText] = useState(lastSearchText)
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
@@ -137,14 +148,15 @@ function DialogInner({guide}: {guide?: Follow10ProgressGuide}) {
|
|||||||
lastSelectedInterest = selectedInterest
|
lastSelectedInterest = selectedInterest
|
||||||
}, [searchText, selectedInterest])
|
}, [searchText, selectedInterest])
|
||||||
|
|
||||||
const {
|
const isForYou = selectedInterest === FOR_YOU_TAB
|
||||||
data: suggestions,
|
|
||||||
isFetching: isFetchingSuggestions,
|
const seeMoreQuery = useGetSuggestedUsersForSeeMoreQuery({
|
||||||
error: suggestionsError,
|
category: isForYou ? undefined : selectedInterest,
|
||||||
} = useGetSuggestedUsersForSeeMoreQuery({
|
|
||||||
category: selectedInterest,
|
|
||||||
limit: 50,
|
limit: 50,
|
||||||
})
|
})
|
||||||
|
const suggestions = seeMoreQuery.data
|
||||||
|
const isFetchingSuggestions = seeMoreQuery.isFetching
|
||||||
|
const suggestionsError = seeMoreQuery.error
|
||||||
const {
|
const {
|
||||||
data: searchResults,
|
data: searchResults,
|
||||||
isFetching: isFetchingSearchResults,
|
isFetching: isFetchingSearchResults,
|
||||||
@@ -277,7 +289,10 @@ function DialogInner({guide}: {guide?: Follow10ProgressGuide}) {
|
|||||||
recId: recIdForLogging,
|
recId: recIdForLogging,
|
||||||
position: position !== -1 ? position : 0,
|
position: position !== -1 ? position : 0,
|
||||||
suggestedDid: item.profile.did,
|
suggestedDid: item.profile.did,
|
||||||
category: selectedInterestRef.current,
|
category:
|
||||||
|
selectedInterestRef.current === FOR_YOU_TAB
|
||||||
|
? null
|
||||||
|
: selectedInterestRef.current,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ export type QueryProps = {
|
|||||||
|
|
||||||
export const getSuggestedUsersForDiscoverQueryKeyRoot =
|
export const getSuggestedUsersForDiscoverQueryKeyRoot =
|
||||||
'unspecced-suggested-users-for-explore'
|
'unspecced-suggested-users-for-explore'
|
||||||
export const createGetSuggestedUsersForDiscoverQueryKey = (
|
export const createGetSuggestedUsersForDiscoverQueryKey = (props: {
|
||||||
props: QueryProps,
|
limit?: number
|
||||||
) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
|
}) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
|
||||||
|
|
||||||
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
@@ -29,7 +29,7 @@ export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
|||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.MINUTES.THREE,
|
staleTime: STALE.MINUTES.THREE,
|
||||||
queryKey: createGetSuggestedUsersForDiscoverQueryKey(props),
|
queryKey: createGetSuggestedUsersForDiscoverQueryKey({limit: props.limit}),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
|
|||||||
@@ -16,21 +16,27 @@ import {useAgent} from '#/state/session'
|
|||||||
export type QueryProps = {
|
export type QueryProps = {
|
||||||
category?: string | null
|
category?: string | null
|
||||||
limit?: number
|
limit?: number
|
||||||
|
enabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSuggestedUsersForSeeMoreQueryKeyRoot =
|
export const getSuggestedUsersForSeeMoreQueryKeyRoot =
|
||||||
'unspecced-suggested-users-for-explore'
|
'unspecced-suggested-users-for-explore'
|
||||||
export const createGetSuggestedUsersForSeeMoreQueryKey = (
|
export const createGetSuggestedUsersForSeeMoreQueryKey = (props: {
|
||||||
props: QueryProps,
|
category?: string | null
|
||||||
) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
|
limit?: number
|
||||||
|
}) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
|
||||||
|
|
||||||
export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
|
enabled: props.enabled ?? true,
|
||||||
staleTime: STALE.MINUTES.THREE,
|
staleTime: STALE.MINUTES.THREE,
|
||||||
queryKey: createGetSuggestedUsersForSeeMoreQueryKey(props),
|
queryKey: createGetSuggestedUsersForSeeMoreQueryKey({
|
||||||
|
category: props.category,
|
||||||
|
limit: props.limit,
|
||||||
|
}),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
|
|||||||
Reference in New Issue
Block a user