flatten may return undefined (#9387)

This commit is contained in:
Samuel Newman
2025-11-14 17:46:20 +02:00
committed by GitHub
parent b422765aed
commit c92ac4abc1
2 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -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
+3 -3
View File
@@ -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 (