flatten may return undefined (#9387)
This commit is contained in:
@@ -25,7 +25,8 @@ export function normalizeTextStyles(
|
|||||||
fontFamily: Alf['fonts']['family']
|
fontFamily: Alf['fonts']['family']
|
||||||
} & Pick<Alf, 'flags'>,
|
} & Pick<Alf, 'flags'>,
|
||||||
) {
|
) {
|
||||||
const s = flatten(styles)
|
const s = flatten(styles) ?? {}
|
||||||
|
|
||||||
// should always be defined on these components
|
// should always be defined on these components
|
||||||
s.fontSize = (s.fontSize || atoms.text_md.fontSize) * fontScale
|
s.fontSize = (s.fontSize || atoms.text_md.fontSize) * fontScale
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {type TextStyle} from 'react-native'
|
import {type StyleProp, type TextStyle} from 'react-native'
|
||||||
import {AppBskyRichtextFacet, RichText as RichTextAPI} from '@atproto/api'
|
import {AppBskyRichtextFacet, RichText as RichTextAPI} from '@atproto/api'
|
||||||
|
|
||||||
import {toShortUrl} from '#/lib/strings/url-helpers'
|
import {toShortUrl} from '#/lib/strings/url-helpers'
|
||||||
@@ -21,7 +21,7 @@ export type RichTextProps = TextStyleProp &
|
|||||||
enableTags?: boolean
|
enableTags?: boolean
|
||||||
authorHandle?: string
|
authorHandle?: string
|
||||||
onLinkPress?: LinkProps['onPress']
|
onLinkPress?: LinkProps['onPress']
|
||||||
interactiveStyle?: TextStyle
|
interactiveStyle?: StyleProp<TextStyle>
|
||||||
emojiMultiplier?: number
|
emojiMultiplier?: number
|
||||||
shouldProxyLinks?: boolean
|
shouldProxyLinks?: boolean
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ export function RichText({
|
|||||||
|
|
||||||
if (!facets?.length) {
|
if (!facets?.length) {
|
||||||
if (isOnlyEmoji(text)) {
|
if (isOnlyEmoji(text)) {
|
||||||
const flattenedStyle = flatten(style)
|
const flattenedStyle = flatten(style) ?? {}
|
||||||
const fontSize =
|
const fontSize =
|
||||||
(flattenedStyle.fontSize ?? a.text_sm.fontSize) * emojiMultiplier
|
(flattenedStyle.fontSize ?? a.text_sm.fontSize) * emojiMultiplier
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user