Remove 'All' category and default to top interest

This commit is contained in:
Eric Bailey
2025-04-03 12:17:39 -05:00
parent b6185039f7
commit 8603a35aea
2 changed files with 16 additions and 33 deletions
+8 -28
View File
@@ -17,7 +17,6 @@ import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useActorSearchPaginated} from '#/state/queries/actor-search' import {useActorSearchPaginated} from '#/state/queries/actor-search'
import {useGetPopularFeedsQuery} from '#/state/queries/feed' import {useGetPopularFeedsQuery} from '#/state/queries/feed'
import {usePreferencesQuery} from '#/state/queries/preferences' import {usePreferencesQuery} from '#/state/queries/preferences'
import {useSuggestedFollowsQuery} from '#/state/queries/suggested-follows'
import {useGetSuggestedFeedsQuery} from '#/state/queries/trending/useGetSuggestedFeedsQuery' import {useGetSuggestedFeedsQuery} from '#/state/queries/trending/useGetSuggestedFeedsQuery'
import {useSuggestedStarterPacksQuery} from '#/state/queries/useSuggestedStarterPacksQuery' import {useSuggestedStarterPacksQuery} from '#/state/queries/useSuggestedStarterPacksQuery'
import {useProgressGuide} from '#/state/shell/progress-guide' import {useProgressGuide} from '#/state/shell/progress-guide'
@@ -195,14 +194,6 @@ export function Explore({
const gate = useGate() const gate = useGate()
const guide = useProgressGuide('follow-10') const guide = useProgressGuide('follow-10')
const [selectedInterest, setSelectedInterest] = useState<string | null>(null) const [selectedInterest, setSelectedInterest] = useState<string | null>(null)
const {
data: suggestedProfiles,
hasNextPage: hasNextSuggestedProfilesPage,
isLoading: isLoadingSuggestedProfiles,
isFetchingNextPage: isFetchingNextSuggestedProfilesPage,
error: suggestedProfilesError,
fetchNextPage: fetchNextSuggestedProfilesPage,
} = useSuggestedFollowsQuery({limit: 3, subsequentPageLimit: 10})
const { const {
data: interestProfiles, data: interestProfiles,
hasNextPage: hasNextInterestProfilesPage, hasNextPage: hasNextInterestProfilesPage,
@@ -213,7 +204,7 @@ export function Explore({
} = useActorSearchPaginated({ } = useActorSearchPaginated({
query: selectedInterest || '', query: selectedInterest || '',
enabled: !!selectedInterest, enabled: !!selectedInterest,
limit: 10, limit: 8,
}) })
const {isReady: canShowSuggestedProfiles} = useLoadEnoughProfiles({ const {isReady: canShowSuggestedProfiles} = useLoadEnoughProfiles({
interest: selectedInterest, interest: selectedInterest,
@@ -232,23 +223,12 @@ export function Explore({
fetchNextPage: fetchNextFeedsPage, fetchNextPage: fetchNextFeedsPage,
} = useGetPopularFeedsQuery({limit: 10}) } = useGetPopularFeedsQuery({limit: 10})
const profiles: typeof suggestedProfiles & typeof interestProfiles = const profiles: typeof interestProfiles = interestProfiles
!selectedInterest ? suggestedProfiles : interestProfiles const hasNextProfilesPage = hasNextInterestProfilesPage
const hasNextProfilesPage = !selectedInterest const isLoadingProfiles = !canShowSuggestedProfiles
? hasNextSuggestedProfilesPage const isFetchingNextProfilesPage = !canShowSuggestedProfiles
: hasNextInterestProfilesPage const profilesError = interestProfilesError
const isLoadingProfiles = !selectedInterest const fetchNextProfilesPage = fetchNextInterestProfilesPage
? isLoadingSuggestedProfiles
: !canShowSuggestedProfiles
const isFetchingNextProfilesPage = !selectedInterest
? isFetchingNextSuggestedProfilesPage
: !canShowSuggestedProfiles
const profilesError = !selectedInterest
? suggestedProfilesError
: interestProfilesError
const fetchNextProfilesPage = !selectedInterest
? fetchNextSuggestedProfilesPage
: fetchNextInterestProfilesPage
const isLoadingMoreProfiles = isFetchingNextProfilesPage && !isLoadingProfiles const isLoadingMoreProfiles = isFetchingNextProfilesPage && !isLoadingProfiles
const onLoadMoreProfiles = useCallback(async () => { const onLoadMoreProfiles = useCallback(async () => {
@@ -709,7 +689,7 @@ export function Explore({
case 'profilePlaceholder': { case 'profilePlaceholder': {
return ( return (
<> <>
{Array.from({length: 3}).map((_, index) => ( {Array.from({length: 6}).map((_, index) => (
<View <View
style={[ style={[
a.px_lg, a.px_lg,
@@ -61,29 +61,32 @@ export function SuggestedAccountsTabBar({
selectedInterest: string | null selectedInterest: string | null
onSelectInterest: (interest: string | null) => void onSelectInterest: (interest: string | null) => void
}) { }) {
const {_} = useLingui()
const interestsDisplayNames = useInterestsDisplayNames() const interestsDisplayNames = 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 = Object.keys(interestsDisplayNames)
.sort(boostInterests(popularInterests)) .sort(boostInterests(popularInterests))
.sort(boostInterests(personalizedInterests)) .sort(boostInterests(personalizedInterests))
useEffect(() => {
if (preferences && !selectedInterest) {
onSelectInterest(interests[0])
}
}, [selectedInterest, preferences, interests, onSelectInterest])
return ( return (
<BlockDrawerGesture> <BlockDrawerGesture>
<Tabs <Tabs
interests={['all', ...interests]} interests={interests}
selectedInterest={selectedInterest || 'all'} selectedInterest={selectedInterest || interests[0]}
onSelectTab={tab => { onSelectTab={tab => {
logger.metric( logger.metric(
'explore:suggestedAccounts:tabPressed', 'explore:suggestedAccounts:tabPressed',
{tab: tab}, {tab: tab},
{statsig: true}, {statsig: true},
) )
onSelectInterest(tab === 'all' ? null : tab) onSelectInterest(tab)
}} }}
hasSearchText={false} hasSearchText={false}
interestsDisplayNames={{ interestsDisplayNames={{
all: _(msg`All`),
...interestsDisplayNames, ...interestsDisplayNames,
}} }}
TabComponent={Tab} TabComponent={Tab}