Add hide to Explore
This commit is contained in:
@@ -1,16 +1,23 @@
|
|||||||
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 {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 TRENDING_TOPICS_COUNT,
|
DEFAULT_LIMIT as TRENDING_TOPICS_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, tokens, useGutters, useTheme} from '#/alf'
|
import {atoms as a, tokens, useGutters, useTheme} from '#/alf'
|
||||||
|
import {Button, ButtonIcon} from '#/components/Button'
|
||||||
import {GradientFill} from '#/components/GradientFill'
|
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 {Trending2_Stroke2_Corner2_Rounded as Trending} from '#/components/icons/Trending2'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {
|
import {
|
||||||
TrendingTopic,
|
TrendingTopic,
|
||||||
TrendingTopicLink,
|
TrendingTopicLink,
|
||||||
@@ -26,9 +33,12 @@ export function ExploreTrendingTopics() {
|
|||||||
|
|
||||||
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 noTopics = !isLoading && !error && !trending?.topics?.length
|
const noTopics = !isLoading && !error && !trending?.topics?.length
|
||||||
|
const {setTrendingDisabled} = useTrendingSettingsApi()
|
||||||
|
const trendingPrompt = Prompt.usePromptControl()
|
||||||
|
|
||||||
return error || noTopics ? null : (
|
return error || noTopics ? null : (
|
||||||
<>
|
<>
|
||||||
@@ -61,6 +71,16 @@ function Inner() {
|
|||||||
<Trans>What people are posting about.</Trans>
|
<Trans>What people are posting about.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
label={_(msg`Hide trending tpoics`)}
|
||||||
|
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]}>
|
||||||
@@ -97,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={() => setTrendingDisabled(true)}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user