diff options
author | Eric Bailey <git@esb.lol> | 2024-12-18 13:37:46 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-18 11:37:46 -0800 |
commit | e7b015f53fd777654326ed0b30174c09673312ef (patch) | |
tree | 82910d8a1faf77fa45076ceaab139dcaa2f4e2d5 /src/screens/Search/components/ExploreTrendingTopics.tsx | |
parent | 05c43ed998430fb7d8d2a57bed54f2f24c71dd88 (diff) | |
download | voidsky-e7b015f53fd777654326ed0b30174c09673312ef.tar.zst |
Trending tracking (#7161)
* Add hide to Explore * Event for show * Add hide events to each location
Diffstat (limited to 'src/screens/Search/components/ExploreTrendingTopics.tsx')
-rw-r--r-- | src/screens/Search/components/ExploreTrendingTopics.tsx | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/screens/Search/components/ExploreTrendingTopics.tsx b/src/screens/Search/components/ExploreTrendingTopics.tsx index be347dcd4..a4766a0f4 100644 --- a/src/screens/Search/components/ExploreTrendingTopics.tsx +++ b/src/screens/Search/components/ExploreTrendingTopics.tsx @@ -1,16 +1,25 @@ +import React from 'react' 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 {useTrendingSettings} from '#/state/preferences/trending' +import { + useTrendingSettings, + useTrendingSettingsApi, +} from '#/state/preferences/trending' import { DEFAULT_LIMIT as TRENDING_TOPICS_COUNT, useTrendingTopics, } from '#/state/queries/trending/useTrendingTopics' import {useTrendingConfig} from '#/state/trending-config' import {atoms as a, tokens, useGutters, useTheme} from '#/alf' +import {Button, ButtonIcon} from '#/components/Button' import {GradientFill} from '#/components/GradientFill' +import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {Trending2_Stroke2_Corner2_Rounded as Trending} from '#/components/icons/Trending2' +import * as Prompt from '#/components/Prompt' import { TrendingTopic, TrendingTopicLink, @@ -26,9 +35,17 @@ export function ExploreTrendingTopics() { function Inner() { const t = useTheme() + const {_} = useLingui() const gutters = useGutters([0, 'compact']) const {data: trending, error, isLoading} = useTrendingTopics() const noTopics = !isLoading && !error && !trending?.topics?.length + const {setTrendingDisabled} = useTrendingSettingsApi() + const trendingPrompt = Prompt.usePromptControl() + + const onConfirmHide = React.useCallback(() => { + logEvent('trendingTopics:hide', {context: 'explore'}) + setTrendingDisabled(true) + }, [setTrendingDisabled]) return error || noTopics ? null : ( <> @@ -61,6 +78,16 @@ function Inner() { <Trans>What people are posting about.</Trans> </Text> </View> + + <Button + label={_(msg`Hide trending tpoics`)} + size="small" + variant="ghost" + color="secondary" + shape="round" + onPress={() => trendingPrompt.open()}> + <ButtonIcon icon={X} /> + </Button> </View> <View style={[a.pt_md, a.pb_lg]}> @@ -97,6 +124,14 @@ 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} + /> </> ) } |