Skip to content

Commit

Permalink
Don't hide recommended (#7166)
Browse files Browse the repository at this point in the history
* Don't hide recommended

* Rm unused
  • Loading branch information
gaearon authored Dec 18, 2024
1 parent 65eccc7 commit 45c6308
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
6 changes: 1 addition & 5 deletions src/lib/statsig/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ export type LogEvents = {

'trendingTopics:show': {}
'trendingTopics:hide': {
context:
| 'sidebar'
| 'interstitial'
| 'explore:trending'
| 'explore:recommendations'
context: 'sidebar' | 'interstitial' | 'explore:trending'
}
}
29 changes: 2 additions & 27 deletions src/screens/Search/components/ExploreRecommendations.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import React from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/macro'

import {logEvent} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection'
import {
useTrendingSettings,
useTrendingSettingsApi,
} from '#/state/preferences/trending'
import {
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
useTrendingTopics,
} from '#/state/queries/trending/useTrendingTopics'
import {useTrendingConfig} from '#/state/trending-config'
import {atoms as a, useGutters, useTheme} from '#/alf'
import {Hashtag_Stroke2_Corner0_Rounded} from '#/components/icons/Hashtag'
import * as Prompt from '#/components/Prompt'
import {
TrendingTopic,
TrendingTopicLink,
Expand All @@ -26,23 +18,14 @@ import {Text} from '#/components/Typography'

export function ExploreRecommendations() {
const {enabled} = useTrendingConfig()
const {trendingDisabled} = useTrendingSettings()
return enabled && !trendingDisabled ? <Inner /> : null
return enabled ? <Inner /> : null
}

function Inner() {
const t = useTheme()
const {_} = useLingui()
const gutters = useGutters([0, 'compact'])
const {data: trending, error, isLoading} = useTrendingTopics()
const noRecs = !isLoading && !error && !trending?.suggested?.length
const {setTrendingDisabled} = useTrendingSettingsApi()
const trendingPrompt = Prompt.usePromptControl()

const onConfirmHide = React.useCallback(() => {
logEvent('trendingTopics:hide', {context: 'explore:recommendations'})
setTrendingDisabled(true)
}, [setTrendingDisabled])

return error || noRecs ? null : (
<>
Expand Down Expand Up @@ -106,14 +89,6 @@ function Inner() {
)}
</View>
</View>

<Prompt.Basic
control={trendingPrompt}
title={_(msg`Hide trending topics?`)}
description={_(msg`You can update this later from your settings.`)}
confirmButtonCta={_(msg`Hide`)}
onConfirm={onConfirmHide}
/>
</>
)
}

0 comments on commit 45c6308

Please sign in to comment.