Use RichText for sp description (#4979)

* Use RichText for sp description

* `isRecord` above

---------

Co-authored-by: Hailey <me@haileyok.com>
zio/stable
Eric Bailey 2024-08-22 17:37:15 -05:00 committed by GitHub
parent b8dbb71781
commit 990bf306c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 8 deletions

View File

@ -31,10 +31,12 @@ import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button' import {Button, ButtonText} from '#/components/Button'
import {useDialogControl} from '#/components/Dialog' import {useDialogControl} from '#/components/Dialog'
import * as FeedCard from '#/components/FeedCard' import * as FeedCard from '#/components/FeedCard'
import {useRichText} from '#/components/hooks/useRichText'
import {LinearGradientBackground} from '#/components/LinearGradientBackground' import {LinearGradientBackground} from '#/components/LinearGradientBackground'
import {ListMaybePlaceholder} from '#/components/Lists' import {ListMaybePlaceholder} from '#/components/Lists'
import {Default as ProfileCard} from '#/components/ProfileCard' import {Default as ProfileCard} from '#/components/ProfileCard'
import * as Prompt from '#/components/Prompt' import * as Prompt from '#/components/Prompt'
import {RichText} from '#/components/RichText'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
const AnimatedPressable = Animated.createAnimatedComponent(Pressable) const AnimatedPressable = Animated.createAnimatedComponent(Pressable)
@ -82,9 +84,15 @@ export function LandingScreen({
return <ListMaybePlaceholder isLoading={true} /> return <ListMaybePlaceholder isLoading={true} />
} }
// Just for types, this cannot be hit
if (!AppBskyGraphStarterpack.isRecord(starterPack.record)) {
return null
}
return ( return (
<LandingScreenLoaded <LandingScreenLoaded
starterPack={starterPack} starterPack={starterPack}
starterPackRecord={starterPack.record}
setScreenState={setScreenState} setScreenState={setScreenState}
moderationOpts={moderationOpts} moderationOpts={moderationOpts}
/> />
@ -93,22 +101,25 @@ export function LandingScreen({
function LandingScreenLoaded({ function LandingScreenLoaded({
starterPack, starterPack,
starterPackRecord: record,
setScreenState, setScreenState,
// TODO apply this to profile card // TODO apply this to profile card
moderationOpts, moderationOpts,
}: { }: {
starterPack: AppBskyGraphDefs.StarterPackView starterPack: AppBskyGraphDefs.StarterPackView
starterPackRecord: AppBskyGraphStarterpack.Record
setScreenState: (state: LoggedOutScreenState) => void setScreenState: (state: LoggedOutScreenState) => void
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
}) { }) {
const {record, creator, listItemsSample, feeds} = starterPack const {creator, listItemsSample, feeds} = starterPack
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const activeStarterPack = useActiveStarterPack() const activeStarterPack = useActiveStarterPack()
const setActiveStarterPack = useSetActiveStarterPack() const setActiveStarterPack = useSetActiveStarterPack()
const {isTabletOrDesktop} = useWebMediaQueries() const {isTabletOrDesktop} = useWebMediaQueries()
const androidDialogControl = useDialogControl() const androidDialogControl = useDialogControl()
const [descriptionRt] = useRichText(record.description || '')
const [appClipOverlayVisible, setAppClipOverlayVisible] = const [appClipOverlayVisible, setAppClipOverlayVisible] =
React.useState(false) React.useState(false)
@ -147,10 +158,6 @@ function LandingScreenLoaded({
} }
} }
if (!AppBskyGraphStarterpack.isRecord(record)) {
return null
}
return ( return (
<CenteredView style={a.flex_1}> <CenteredView style={a.flex_1}>
<ScrollView <ScrollView
@ -192,9 +199,7 @@ function LandingScreenLoaded({
</LinearGradientBackground> </LinearGradientBackground>
<View style={[a.gap_2xl, a.mx_lg, a.my_2xl]}> <View style={[a.gap_2xl, a.mx_lg, a.my_2xl]}>
{record.description ? ( {record.description ? (
<Text style={[a.text_md, t.atoms.text_contrast_medium]}> <RichText value={descriptionRt} style={[a.text_md]} />
{record.description}
</Text>
) : null} ) : null}
<View style={[a.gap_sm]}> <View style={[a.gap_sm]}>
<Button <Button