mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[🐴] add emoji multiplier prop to RichText and bump it up for DMs (#4229)

* add emoji multiplier prop to RichText and bump it up for DMs

* remove background if only emoji

* Handle more emoji

* Adjust emoji regex and length

* Fix bad merge conflict res

* Fix logic

* Revert to emoji specific regex

---------

Co-authored-by: Eric Bailey <git@esb.lol>

authored by samuel.fm

Eric Bailey and committed by
GitHub
b51640fb 5cda807d

+36 -28
+13 -7
src/components/RichText.tsx
··· 28 28 authorHandle, 29 29 onLinkPress, 30 30 interactiveStyle, 31 + emojiMultiplier = 1.85, 31 32 }: TextStyleProp & 32 33 Pick<TextProps, 'selectable'> & { 33 34 value: RichTextAPI | string ··· 38 39 authorHandle?: string 39 40 onLinkPress?: LinkProps['onPress'] 40 41 interactiveStyle?: TextStyle 42 + emojiMultiplier?: number 41 43 }) { 42 44 const richText = React.useMemo( 43 45 () => ··· 57 59 const {text, facets} = richText 58 60 59 61 if (!facets?.length) { 60 - if (text.length <= 5 && /^\p{Extended_Pictographic}+$/u.test(text)) { 62 + if (isOnlyEmoji(text)) { 63 + const fontSize = 64 + (flattenedStyle.fontSize ?? a.text_sm.fontSize) * emojiMultiplier 61 65 return ( 62 66 <Text 63 67 selectable={selectable} 64 68 testID={testID} 65 - style={[ 66 - { 67 - fontSize: 26, 68 - lineHeight: 30, 69 - }, 70 - ]} 69 + style={[plainStyles, {fontSize}]} 71 70 // @ts-ignore web only -prf 72 71 dataSet={WORD_WRAP}> 73 72 {text} ··· 247 246 </React.Fragment> 248 247 ) 249 248 } 249 + 250 + export function isOnlyEmoji(text: string) { 251 + return ( 252 + text.length <= 15 && 253 + /^[\p{Emoji_Presentation}\p{Extended_Pictographic}]+$/u.test(text) 254 + ) 255 + }
+23 -21
src/components/dms/MessageItem.tsx
··· 21 21 import {ActionsWrapper} from '#/components/dms/ActionsWrapper' 22 22 import {InlineLinkText} from '#/components/Link' 23 23 import {Text} from '#/components/Typography' 24 - import {RichText} from '../RichText' 24 + import {isOnlyEmoji, RichText} from '../RichText' 25 25 import {MessageItemEmbed} from './MessageItemEmbed' 26 26 27 27 let MessageItem = ({ ··· 87 87 )} 88 88 {rt.text.length > 0 && ( 89 89 <View 90 - style={[ 91 - a.py_sm, 92 - a.my_2xs, 93 - a.rounded_md, 94 - { 95 - paddingLeft: 14, 96 - paddingRight: 14, 97 - backgroundColor: isFromSelf 98 - ? isPending 99 - ? pendingColor 100 - : t.palette.primary_500 101 - : t.palette.contrast_50, 102 - borderRadius: 17, 103 - }, 104 - isFromSelf ? a.self_end : a.self_start, 105 - isFromSelf 106 - ? {borderBottomRightRadius: isLastInGroup ? 2 : 17} 107 - : {borderBottomLeftRadius: isLastInGroup ? 2 : 17}, 108 - ]}> 90 + style={ 91 + !isOnlyEmoji(message.text) && [ 92 + a.py_sm, 93 + a.my_2xs, 94 + a.rounded_md, 95 + { 96 + paddingLeft: 14, 97 + paddingRight: 14, 98 + backgroundColor: isFromSelf 99 + ? isPending 100 + ? pendingColor 101 + : t.palette.primary_500 102 + : t.palette.contrast_50, 103 + borderRadius: 17, 104 + }, 105 + isFromSelf ? a.self_end : a.self_start, 106 + isFromSelf 107 + ? {borderBottomRightRadius: isLastInGroup ? 2 : 17} 108 + : {borderBottomLeftRadius: isLastInGroup ? 2 : 17}, 109 + ] 110 + }> 109 111 <RichText 110 112 value={rt} 111 113 style={[ 112 114 a.text_md, 113 - a.leading_snug, 114 115 isFromSelf && {color: t.palette.white}, 115 116 isPending && 116 117 t.name !== 'light' && {color: t.palette.primary_300}, 117 118 ]} 118 119 interactiveStyle={a.underline} 119 120 enableTags 121 + emojiMultiplier={3} 120 122 /> 121 123 </View> 122 124 )}