tidy up post reasons (#9194)
This commit is contained in:
@@ -1,54 +1,51 @@
|
||||
import {type StyleProp, StyleSheet, type TextStyle} from 'react-native'
|
||||
import {type StyleProp, type TextStyle} from 'react-native'
|
||||
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {type TypographyVariant} from '#/lib/ThemeContext'
|
||||
import {useFeedSourceInfoQuery} from '#/state/queries/feed'
|
||||
import {TextLinkOnWebOnly} from './Link'
|
||||
import {atoms as a, platform} from '#/alf'
|
||||
import {WebOnlyInlineLinkText} from '#/components/Link'
|
||||
import {LoadingPlaceholder} from './LoadingPlaceholder'
|
||||
|
||||
export function FeedNameText({
|
||||
type = 'md',
|
||||
uri,
|
||||
href,
|
||||
lineHeight,
|
||||
numberOfLines,
|
||||
style,
|
||||
}: {
|
||||
type?: TypographyVariant
|
||||
uri: string
|
||||
href: string
|
||||
lineHeight?: number
|
||||
numberOfLines?: number
|
||||
style?: StyleProp<TextStyle>
|
||||
}) {
|
||||
const {data, isError} = useFeedSourceInfoQuery({uri})
|
||||
|
||||
let inner
|
||||
if (data?.displayName || isError) {
|
||||
if (data || isError) {
|
||||
const displayName = data?.displayName || uri.split('/').pop() || ''
|
||||
inner = (
|
||||
<TextLinkOnWebOnly
|
||||
type={type}
|
||||
<WebOnlyInlineLinkText
|
||||
to={href}
|
||||
label={displayName}
|
||||
style={style}
|
||||
lineHeight={lineHeight}
|
||||
numberOfLines={numberOfLines}
|
||||
href={href}
|
||||
text={sanitizeDisplayName(displayName)}
|
||||
/>
|
||||
numberOfLines={numberOfLines}>
|
||||
{sanitizeDisplayName(displayName)}
|
||||
</WebOnlyInlineLinkText>
|
||||
)
|
||||
} else {
|
||||
inner = (
|
||||
<LoadingPlaceholder
|
||||
width={80}
|
||||
height={8}
|
||||
style={styles.loadingPlaceholder}
|
||||
style={[
|
||||
a.ml_2xs,
|
||||
platform({
|
||||
native: [a.mt_2xs],
|
||||
web: [{top: -1}],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return inner
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
loadingPlaceholder: {position: 'relative', top: 1, left: 2},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user