Trending tracking 2 (#7162)
* Move (cherry picked from commitbfb96f4ce2) * Add to recommeded too (cherry picked from commite6844883a6) --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
@@ -239,6 +239,10 @@ export type LogEvents = {
|
|||||||
|
|
||||||
'trendingTopics:show': {}
|
'trendingTopics:show': {}
|
||||||
'trendingTopics:hide': {
|
'trendingTopics:hide': {
|
||||||
context: 'sidebar' | 'interstitial' | 'explore'
|
context:
|
||||||
|
| 'sidebar'
|
||||||
|
| 'interstitial'
|
||||||
|
| 'explore:trending'
|
||||||
|
| 'explore:recommendations'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {useTrendingSettings} from '#/state/preferences/trending'
|
import {
|
||||||
|
useTrendingSettings,
|
||||||
|
useTrendingSettingsApi,
|
||||||
|
} from '#/state/preferences/trending'
|
||||||
import {
|
import {
|
||||||
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
|
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
|
||||||
useTrendingTopics,
|
useTrendingTopics,
|
||||||
} from '#/state/queries/trending/useTrendingTopics'
|
} from '#/state/queries/trending/useTrendingTopics'
|
||||||
import {useTrendingConfig} from '#/state/trending-config'
|
import {useTrendingConfig} from '#/state/trending-config'
|
||||||
import {atoms as a, useGutters, useTheme} from '#/alf'
|
import {atoms as a, useGutters, useTheme} from '#/alf'
|
||||||
|
import {Button, ButtonIcon} from '#/components/Button'
|
||||||
import {Hashtag_Stroke2_Corner0_Rounded} from '#/components/icons/Hashtag'
|
import {Hashtag_Stroke2_Corner0_Rounded} from '#/components/icons/Hashtag'
|
||||||
|
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {
|
import {
|
||||||
TrendingTopic,
|
TrendingTopic,
|
||||||
TrendingTopicLink,
|
TrendingTopicLink,
|
||||||
@@ -25,17 +34,26 @@ export function ExploreRecommendations() {
|
|||||||
|
|
||||||
function Inner() {
|
function Inner() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const {_} = useLingui()
|
||||||
const gutters = useGutters([0, 'compact'])
|
const gutters = useGutters([0, 'compact'])
|
||||||
const {data: trending, error, isLoading} = useTrendingTopics()
|
const {data: trending, error, isLoading} = useTrendingTopics()
|
||||||
const noRecs = !isLoading && !error && !trending?.suggested?.length
|
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 : (
|
return error || noRecs ? null : (
|
||||||
<>
|
<>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
a.flex_row,
|
||||||
isWeb
|
isWeb
|
||||||
? [a.flex_row, a.px_lg, a.py_lg, a.pt_2xl, a.gap_md]
|
? [a.px_lg, a.py_lg, a.pt_2xl, a.gap_md]
|
||||||
: [{flexDirection: 'row-reverse'}, a.p_lg, a.pt_2xl, a.gap_md],
|
: [a.p_lg, a.pt_2xl, a.gap_md],
|
||||||
a.border_b,
|
a.border_b,
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
]}>
|
]}>
|
||||||
@@ -54,6 +72,15 @@ function Inner() {
|
|||||||
<Trans>Feeds we think you might like.</Trans>
|
<Trans>Feeds we think you might like.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
<Button
|
||||||
|
label={_(msg`Hide trending topics`)}
|
||||||
|
size="small"
|
||||||
|
variant="ghost"
|
||||||
|
color="secondary"
|
||||||
|
shape="round"
|
||||||
|
onPress={() => trendingPrompt.open()}>
|
||||||
|
<ButtonIcon icon={X} />
|
||||||
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={[a.pt_md, a.pb_lg]}>
|
<View style={[a.pt_md, a.pb_lg]}>
|
||||||
@@ -90,6 +117,14 @@ function Inner() {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</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}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function Inner() {
|
|||||||
const trendingPrompt = Prompt.usePromptControl()
|
const trendingPrompt = Prompt.usePromptControl()
|
||||||
|
|
||||||
const onConfirmHide = React.useCallback(() => {
|
const onConfirmHide = React.useCallback(() => {
|
||||||
logEvent('trendingTopics:hide', {context: 'explore'})
|
logEvent('trendingTopics:hide', {context: 'explore:trending'})
|
||||||
setTrendingDisabled(true)
|
setTrendingDisabled(true)
|
||||||
}, [setTrendingDisabled])
|
}, [setTrendingDisabled])
|
||||||
|
|
||||||
@@ -51,9 +51,10 @@ function Inner() {
|
|||||||
<>
|
<>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
a.flex_row,
|
||||||
isWeb
|
isWeb
|
||||||
? [a.flex_row, a.px_lg, a.py_lg, a.pt_2xl, a.gap_md]
|
? [a.px_lg, a.py_lg, a.pt_2xl, a.gap_md]
|
||||||
: [{flexDirection: 'row-reverse'}, a.p_lg, a.pt_2xl, a.gap_md],
|
: [a.p_lg, a.pt_2xl, a.gap_md],
|
||||||
a.border_b,
|
a.border_b,
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
]}>
|
]}>
|
||||||
@@ -78,9 +79,8 @@ function Inner() {
|
|||||||
<Trans>What people are posting about.</Trans>
|
<Trans>What people are posting about.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Hide trending tpoics`)}
|
label={_(msg`Hide trending topics`)}
|
||||||
size="small"
|
size="small"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
Reference in New Issue
Block a user