Skip to content

Commit 28d8e94

Browse files
authored
fix jumbo emojis for messages sent with a per-message-profile (#530)
### Description added a regex to the rendering of messages to detect jumbo emojis. the regex used is: ``` ^(<img[^>]*data-mx-emoticon[^>]*\/>){1,20}$ ``` Fixes #458 #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). no AI was used in the creation of this PR
2 parents ec2dcfb + 7338be2 commit 28d8e94

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
fix the display of jumbo emojis on messages sent with a persona

src/app/components/message/MsgTypeRenderers.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
121121

122122
const isJumbo = useMemo(() => {
123123
if (!trimmedBody || trimmedBody.length >= 500) return false;
124+
if (
125+
(unwrappedPerMessageProfileMessage ?? safeCustomBody)?.match(
126+
/^(<img[^>]*data-mx-emoticon[^>]*\/>){1,20}$/i
127+
)
128+
)
129+
return true;
124130
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
125131

126132
if (trimmedBody.includes(':')) {
@@ -129,7 +135,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
129135
}
130136

131137
return true;
132-
}, [trimmedBody, safeCustomBody]);
138+
}, [unwrappedPerMessageProfileMessage, trimmedBody, safeCustomBody]);
133139

134140
if (!body && !customBody) return <BrokenContent body={customBody ?? body} />;
135141

@@ -139,7 +145,11 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
139145
if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) {
140146
// unwrap per-message profile fallback if present
141147
return (
142-
<MessageTextBody preWrap={typeof customBody !== 'string'} style={style}>
148+
<MessageTextBody
149+
preWrap={typeof customBody !== 'string'}
150+
style={style}
151+
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
152+
>
143153
{renderBody({
144154
body: trimmedBody,
145155
customBody: unwrappedPerMessageProfileMessage,

0 commit comments

Comments
 (0)