Handle service config, enablement, load states, update lex contract

This commit is contained in:
Eric Bailey
2024-12-16 17:08:56 -06:00
parent 0643233a66
commit 64e47cced3
11 changed files with 289 additions and 172 deletions
+4 -107
View File
@@ -25,21 +25,18 @@ import {
ProfileCardFeedLoadingPlaceholder,
} from '#/view/com/util/LoadingPlaceholder'
import {UserAvatar} from '#/view/com/util/UserAvatar'
import {atoms as a, tokens,useTheme, ViewStyleProp} from '#/alf'
import {ExploreTrendingTopics} from '#/screens/Search/components/ExploreTrendingTopics'
import {atoms as a, useTheme, ViewStyleProp} from '#/alf'
import {Button} from '#/components/Button'
import * as FeedCard from '#/components/FeedCard'
import {GradientFill} from '#/components/GradientFill'
import {ArrowBottom_Stroke2_Corner0_Rounded as ArrowBottom} from '#/components/icons/Arrow'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
import {Props as SVGIconProps} from '#/components/icons/common'
import {ListSparkle_Stroke2_Corner0_Rounded as ListSparkle} from '#/components/icons/ListSparkle'
import {Trending2_Stroke2_Corner2_Rounded as Trending} from '#/components/icons/Trending2'
import {UserCircle_Stroke2_Corner0_Rounded as Person} from '#/components/icons/UserCircle'
import {Loader} from '#/components/Loader'
import * as StarterPackSuggestions from '#/components/StarterPack/Suggestions'
import * as TrendingTopics from '#/components/TrendingTopics'
import {Text} from '#/components/Typography'
import {ExploreTrendingTopics} from "#/screens/Search/components/ExploreTrendingTopics"
function SuggestedItemsHeader({
title,
@@ -251,7 +248,6 @@ type ExploreScreenItems =
| {
type: 'trendingTopics'
key: string
topics: string[]
}
| {
type: 'suggestedStarterPacks'
@@ -349,89 +345,8 @@ export function Explore() {
i.push({
type: 'trendingTopics',
key: `trending-topics`,
topics: [
'#atproto',
'South Korea',
'Wired',
'Basket Weaving',
'Coup',
'Chappel Roan',
'the juice',
'Superman',
'#FCF',
'Open Web',
],
})
/*
i.push({
type: 'header',
key: 'starter-packs-header',
title: _(msg`Starter packs`),
description: _(msg`Find accounts to follow based on your interests.`),
icon: PersonGroup,
})
i.push({
type: 'suggestedStarterPacks',
key: 'suggested-starter-packs',
starterPacks: [
{
uri: 'at://did:plc:ragtjsm2j2vknwkz3zp4oxrd/app.bsky.graph.starterpack/3kvaphb2hpf2u',
cid: '',
indexedAt: '',
record: {
$type: 'app.bsky.graph.starterpack',
description:
'Engineers who work on or discuss the ATProtocol, both at Bluesky and in the community',
list: 'at://did:plc:ragtjsm2j2vknwkz3zp4oxrd/app.bsky.graph.list/3kvaphagg4e2l',
name: 'ATProtocol Hackers',
},
creator: {
did: 'did:plc:ragtjsm2j2vknwkz3zp4oxrd',
handle: 'pfrazee.com',
displayName: 'Paul Frazee',
},
},
{
uri: 'at://did:plc:qrllvid7s54k4hnwtqxwetrf/app.bsky.graph.starterpack/3kvuh7u324m2c',
cid: '',
indexedAt: '',
record: {
$type: 'app.bsky.graph.starterpack',
createdAt: '2024-06-26T23:23:01.073Z',
description:
'Legal practice, scholarship, journalism, and argument',
feeds: [],
list: 'at://did:plc:qrllvid7s54k4hnwtqxwetrf/app.bsky.graph.list/3kvuh7twnjc2m',
name: 'Bluesky for Law',
},
creator: {
did: 'did:plc:qrllvid7s54k4hnwtqxwetrf',
handle: 'joshuajfriedman.com',
displayName: 'Joshua J. Friedman',
},
},
{
uri: 'at://did:plc:7exlcsle4mjfhu3wnhcgizz6/app.bsky.graph.starterpack/3laotg2fqva2h',
cid: '',
indexedAt: '',
record: {
$type: 'app.bsky.graph.starterpack',
createdAt: '2024-11-11T17:22:22.743Z',
description: 'people who work at the website, the verge dot com',
list: 'at://did:plc:7exlcsle4mjfhu3wnhcgizz6/app.bsky.graph.list/3laotg2bjok2d',
name: 'The Verge staff',
},
creator: {
did: 'did:plc:7exlcsle4mjfhu3wnhcgizz6',
handle: 'theverge.com',
displayName: 'The Verge',
},
},
],
})
*/
i.push({
type: 'header',
key: 'suggested-follows-header',
@@ -596,25 +511,7 @@ export function Explore() {
)
}
case 'trendingTopics': {
return (
<>
<SuggestedItemsHeader
title={_(msg`Trending`)}
description={_(msg`What people are posting about now.`)}
icon={Trending}
titleChild={
<View
style={[a.py_xs, a.px_sm, a.rounded_sm, a.overflow_hidden]}>
<GradientFill gradient={tokens.gradients.primary} />
<Text style={[a.text_md, a.font_heavy]}>BETA</Text>
</View>
}
/>
<View style={[a.pt_md, a.pb_lg]}>
<ExploreTrendingTopics />
</View>
</>
)
return <ExploreTrendingTopics />
}
case 'suggestedStarterPacks': {
return (
@@ -696,7 +593,7 @@ export function Explore() {
}
}
},
[_, t, moderationOpts],
[t, moderationOpts],
)
// note: actually not a screen, instead it's nested within
@@ -6,7 +6,11 @@ import {
useTrendingSettings,
useTrendingSettingsApi,
} from '#/state/preferences/trending'
import {useTrendingTopics} from '#/state/queries/trending/useTrendingTopics'
import {
DEFAULT_LIMIT as TRENDING_TOPICS_COUNT,
useTrendingTopics,
} from '#/state/queries/trending/useTrendingTopics'
import {useTrendingConfig} from '#/state/trending-config'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon} from '#/components/Button'
import {Divider} from '#/components/Divider'
@@ -21,8 +25,9 @@ import {
import {Text} from '#/components/Typography'
export function SidebarTrendingTopics() {
const {enabled} = useTrendingConfig()
const {trendingSidebarHidden} = useTrendingSettings()
return trendingSidebarHidden ? null : <Inner />
return !enabled ? null : trendingSidebarHidden ? null : <Inner />
}
function Inner() {
@@ -30,9 +35,8 @@ function Inner() {
const {_} = useLingui()
const trendingPrompt = Prompt.usePromptControl()
const {setTrendingSidebarHidden} = useTrendingSettingsApi()
const {data: topics, error, isLoading} = useTrendingTopics()
const noTopics = !isLoading && !error && !topics
const {data: trending, error, isLoading} = useTrendingTopics()
const noTopics = !isLoading && !error && !trending?.topics
return error || noTopics ? null : (
<>
@@ -61,12 +65,14 @@ function Inner() {
<View style={[a.flex_row, a.flex_wrap, a.gap_xs]}>
{isLoading ? (
Array(8)
Array(TRENDING_TOPICS_COUNT)
.fill(0)
.map((_, i) => <TrendingTopicSkeleton key={i} size="small" />)
) : error || !topics ? null : (
.map((_n, i) => (
<TrendingTopicSkeleton key={i} size="small" index={i} />
))
) : !trending?.topics ? null : (
<>
{topics.map(topic => (
{trending.topics.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}>
{({hovered}) => (
<TrendingTopic