Skip to content

Commit 4fa6172

Browse files
mountinyOSBotify
authored andcommitted
Merge pull request #78630 from Expensify/revert-77790-paulnjs-fix/76899
(cherry picked from commit 28b7d79) (cherry-picked to staging by mountiny)
1 parent fe7c100 commit 4fa6172

File tree

7 files changed

+47
-131
lines changed

7 files changed

+47
-131
lines changed

cspell.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"words": [
99
"--longpress",
1010
"Accelo",
11-
"accountid",
1211
"achreimburse",
1312
"actool",
1413
"adbd",
@@ -44,7 +43,6 @@
4443
"approvalstatus",
4544
"appversion",
4645
"archivado",
47-
"Areport",
4846
"ARGB",
4947
"armeabi",
5048
"armv7",
@@ -59,6 +57,7 @@
5957
"asar",
6058
"ASPAC",
6159
"assetlinks",
60+
"accountid",
6261
"attributes.accountid",
6362
"attributes.reportid",
6463
"authorised",
@@ -105,17 +104,17 @@
105104
"Buildscript",
106105
"Bushwick",
107106
"BYOC",
108-
"cacerts",
109107
"capitalone",
110108
"CAROOT",
111109
"Carta",
110+
"cacerts",
111+
"changeit",
112112
"ccache",
113113
"ccupload",
114114
"cdfbmo",
115115
"Certinia",
116116
"Certinia's",
117117
"CFPB",
118-
"changeit",
119118
"chargeback",
120119
"Charleson",
121120
"Checkmark",
@@ -141,7 +140,6 @@
141140
"contenteditable",
142141
"copiloted",
143142
"copiloting",
144-
"copyable",
145143
"Corpay",
146144
"Countertop",
147145
"CPPFLAGS",
@@ -154,12 +152,13 @@
154152
"customfield",
155153
"customise",
156154
"dateexported",
157-
"deapex",
158-
"deapexer",
159155
"debitamount",
160156
"deburr",
161157
"deburred",
158+
"REJECTEDTRANSACTION",
162159
"Deel",
160+
"deapex",
161+
"deapexer",
163162
"deeplink",
164163
"deeplinked",
165164
"deeplinking",
@@ -184,9 +183,7 @@
184183
"Drycleaning",
185184
"DSYM",
186185
"dsyms",
187-
"Dtype",
188186
"durationMillis",
189-
"DYNAMICEXTERNAL",
190187
"e2edelta",
191188
"ecash",
192189
"ecconnrefused",
@@ -226,12 +223,12 @@
226223
"Expensable",
227224
"expensescount",
228225
"Expensi",
226+
"Expensidev",
229227
"Expensicon",
230228
"Expensicons",
231229
"expensicorp",
232-
"Expensidev",
233-
"EXPENSIDEV",
234230
"Expensifier",
231+
"EXPENSIDEV",
235232
"EXPENSIFYAPI",
236233
"expensifyhelp",
237234
"expensifylite",
@@ -351,8 +348,8 @@
351348
"keyvaluepairs",
352349
"KHTML",
353350
"killall",
354-
"kilometre",
355351
"kilometres",
352+
"kilometre",
356353
"Kort",
357354
"Kowalski",
358355
"Krasoń",
@@ -410,9 +407,6 @@
410407
"Mobasher",
411408
"mobiexpensifyg",
412409
"mobileprovision",
413-
"moveElemsAttrsToGroup",
414-
"moveGroupAttrsToElems",
415-
"mple",
416410
"mswin",
417411
"msword",
418412
"mtrl",
@@ -458,9 +452,9 @@
458452
"Nonstore",
459453
"Nonupholstered",
460454
"noopener",
461-
"noprompt",
462455
"noreferer",
463456
"noreferrer",
457+
"noprompt",
464458
"nosymbol",
465459
"Noto",
466460
"NSQS",
@@ -483,7 +477,6 @@
483477
"OLDDOT",
484478
"onclosetag",
485479
"Oncorp",
486-
"oneline",
487480
"oneteam",
488481
"oneui",
489482
"onfido",
@@ -584,10 +577,8 @@
584577
"REIMBURSER",
585578
"reimbursible",
586579
"Reimbursments",
587-
"REJECTEDTRANSACTION",
588580
"remotedesktop",
589581
"remotesync",
590-
"removeHiddenElems",
591582
"REPORTPREVIEW",
592583
"requestee",
593584
"Resawing",
@@ -596,12 +587,11 @@
596587
"retryable",
597588
"Reupholstery",
598589
"rideshare",
599-
"RNCORE",
590+
"rock",
600591
"RNFS",
601592
"rnmapbox",
602593
"RNTL",
603594
"RNVP",
604-
"rock",
605595
"Roni",
606596
"Rosiclair",
607597
"rpartition",
@@ -621,43 +611,40 @@
621611
"Schengen",
622612
"Schiffli",
623613
"SCIM",
624-
"scriptname",
625614
"sdkmanager",
615+
"scriptname",
626616
"seamless",
627617
"Segoe",
628618
"seguiemj",
629-
"Selec",
630619
"Sepa",
631620
"serveo",
632-
"setuptools",
633621
"Sharees",
634622
"Sharons",
635623
"shellcheck",
636624
"shellenv",
625+
"Skydo",
637626
"shipit",
638627
"shouldshowellipsis",
639628
"signingkey",
640629
"signup",
641630
"Signup",
642631
"simctl",
643632
"skip_codesigning",
644-
"Skydo",
645633
"Slurper",
646634
"SMARTREPORT",
647635
"Smartscan",
648636
"soloader",
649637
"SONIFICATION",
650638
"Speedscope",
651-
"Splittable",
652639
"Spotnana",
653640
"spreadsheetml",
654641
"srgb",
655642
"SSAE",
656-
"stackoverflow",
657643
"startdate",
658644
"stdev",
659645
"stdlib",
660646
"storepass",
647+
"stackoverflow",
661648
"STORYLANE",
662649
"strikethrough",
663650
"Strikethrough",
@@ -765,7 +752,6 @@
765752
"webrtc",
766753
"welldone",
767754
"Woohoo",
768-
"Wooo",
769755
"Wordmark",
770756
"wordprocessingml",
771757
"worklet",
@@ -805,7 +791,21 @@
805791
"zoneinfo",
806792
"zxcv",
807793
"zxldvw",
808-
"مثال"
794+
"inputmethod",
795+
"copyable",
796+
"مثال",
797+
"moveElemsAttrsToGroup",
798+
"removeHiddenElems",
799+
"moveGroupAttrsToElems",
800+
"Dtype",
801+
"Areport",
802+
"mple",
803+
"Selec",
804+
"setuptools",
805+
"DYNAMICEXTERNAL",
806+
"RNCORE",
807+
"Wooo",
808+
"Splittable"
809809
],
810810
"ignorePaths": [
811811
"src/languages/de.ts",

src/components/EmojiWithTooltip/index.ios.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import Text from '@components/Text';
33
import useThemeStyles from '@hooks/useThemeStyles';
44
import type EmojiWithTooltipProps from './types';
55

6-
function EmojiWithTooltip({emojiCode, style = {}, isMedium = false, isOnSeparateLine = false}: EmojiWithTooltipProps) {
6+
function EmojiWithTooltip({emojiCode, style = {}, isMedium = false}: EmojiWithTooltipProps) {
77
const styles = useThemeStyles();
88
const isCustomEmoji = emojiCode === '\uE100';
9-
if (isOnSeparateLine) {
10-
return <Text style={[styles.emojisWithTextFontSizeAligned, isCustomEmoji && styles.customEmojiFontAlignment]}>{emojiCode}</Text>;
11-
}
129

1310
return isMedium ? (
1411
<Text style={style}>

src/components/EmojiWithTooltip/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ type EmojiWithTooltipProps = {
44
emojiCode: string;
55
style?: StyleProp<TextStyle>;
66
isMedium?: boolean;
7-
isOnSeparateLine?: boolean;
87
};
98

109
export default EmojiWithTooltipProps;

src/components/HTMLEngineProvider/HTMLRenderers/EmojiRenderer.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import React from 'react';
1+
import React, {useMemo} from 'react';
22
import type {TextStyle} from 'react-native';
33
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
44
import EmojiWithTooltip from '@components/EmojiWithTooltip';
55
import useThemeStyles from '@hooks/useThemeStyles';
66

77
function EmojiRenderer({tnode, style: styleProp}: CustomRendererProps<TText | TPhrasing>) {
88
const styles = useThemeStyles();
9+
const style = useMemo(() => {
10+
if ('islarge' in tnode.attributes) {
11+
return [styleProp as TextStyle, styles.onlyEmojisText];
12+
}
913

10-
let style;
11-
if ('islarge' in tnode.attributes) {
12-
style = [styleProp as TextStyle, styles.onlyEmojisText];
13-
} else if ('ismedium' in tnode.attributes) {
14-
style = [styleProp as TextStyle, styles.emojisWithTextFontSize, styles.verticalAlignTopText];
15-
} else {
16-
style = null;
17-
}
14+
if ('ismedium' in tnode.attributes) {
15+
return [styleProp as TextStyle, styles.emojisWithTextFontSize, styles.verticalAlignTopText];
16+
}
1817

18+
return null;
19+
}, [tnode.attributes, styles, styleProp]);
1920
return (
2021
<EmojiWithTooltip
21-
isOnSeparateLine={'oneline' in tnode.attributes}
2222
style={[style, styles.cursorDefault, styles.emojiDefaultStyles]}
2323
emojiCode={'data' in tnode ? tnode.data : ''}
2424
isMedium={'ismedium' in tnode.attributes}

src/libs/EmojiUtils.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,6 @@ function getZWNJCursorOffset(text: string, cursorPosition: number | undefined |
696696
return textWithZWNJBeforeCursor.length - textBeforeCursor.length;
697697
}
698698

699-
function isEmojiOnSeparateLine(line: string) {
700-
const trimmed = line.replaceAll(/<br\s*\/?>/gi, '').trim();
701-
return /^<emoji>.*<\/emoji>$/.test(trimmed);
702-
}
703-
704699
export type {HeaderIndices, EmojiPickerList, EmojiPickerListItem};
705700

706701
export {
@@ -730,5 +725,4 @@ export {
730725
processFrequentlyUsedEmojis,
731726
insertZWNJBetweenDigitAndEmoji,
732727
getZWNJCursorOffset,
733-
isEmojiOnSeparateLine,
734728
};

src/pages/home/report/comment/TextCommentFragment.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Str} from 'expensify-common';
22
import isEmpty from 'lodash/isEmpty';
3-
import React, {useEffect} from 'react';
3+
import React, {memo, useEffect, useMemo} from 'react';
44
import type {StyleProp, TextStyle} from 'react-native';
55
import Text from '@components/Text';
66
import ZeroWidthView from '@components/ZeroWidthView';
@@ -11,7 +11,7 @@ import useTheme from '@hooks/useTheme';
1111
import useThemeStyles from '@hooks/useThemeStyles';
1212
import convertToLTR from '@libs/convertToLTR';
1313
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
14-
import {containsOnlyCustomEmoji as containsOnlyCustomEmojiUtil, containsOnlyEmojis as containsOnlyEmojisUtil, isEmojiOnSeparateLine, splitTextWithEmojis} from '@libs/EmojiUtils';
14+
import {containsOnlyCustomEmoji as containsOnlyCustomEmojiUtil, containsOnlyEmojis as containsOnlyEmojisUtil, splitTextWithEmojis} from '@libs/EmojiUtils';
1515
import Parser from '@libs/Parser';
1616
import Performance from '@libs/Performance';
1717
import {getHtmlWithAttachmentID, getTextFromHtml} from '@libs/ReportActionsUtils';
@@ -62,7 +62,7 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
6262

6363
const message = isEmpty(iouMessage) ? text : iouMessage;
6464

65-
const processedTextArray = splitTextWithEmojis(message);
65+
const processedTextArray = useMemo(() => splitTextWithEmojis(message), [message]);
6666

6767
useEffect(() => {
6868
Performance.markEnd(CONST.TIMING.SEND_MESSAGE, {message: text});
@@ -74,7 +74,7 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
7474
// on native, we render it as text, not as html
7575
// on other device, only render it as text if the only difference is <br /> tag
7676
const containsOnlyEmojis = containsOnlyEmojisUtil(text ?? '');
77-
const containsOnlyCustomEmoji = containsOnlyCustomEmojiUtil(text);
77+
const containsOnlyCustomEmoji = useMemo(() => containsOnlyCustomEmojiUtil(text), [text]);
7878
const containsEmojis = CONST.REGEX.ALL_EMOJIS.test(text ?? '');
7979
if (!shouldRenderAsText(html, text ?? '') && !(containsOnlyEmojis && styleAsDeleted)) {
8080
const editedTag = fragment?.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''}></edited>` : '';
@@ -90,15 +90,7 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
9090
if (!htmlContent.includes('<emoji>')) {
9191
htmlContent = Parser.replace(htmlContent, {filterRules: ['emoji'], shouldEscapeText: false});
9292
}
93-
const lines = htmlContent.split(/<br\s*\/?>/i);
94-
const processedLines = lines.map((line) => {
95-
if (isEmojiOnSeparateLine(line)) {
96-
return line.replace('<emoji>', '<emoji ismedium oneline >');
97-
}
98-
return line.replace('<emoji>', '<emoji ismedium>');
99-
});
100-
101-
htmlContent = processedLines.join('<br />');
93+
htmlContent = Str.replaceAll(htmlContent, '<emoji>', '<emoji ismedium>');
10294
}
10395

10496
let htmlWithTag = editedTag ? `${htmlContent}${editedTag}` : htmlContent;
@@ -166,4 +158,4 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
166158
);
167159
}
168160

169-
export default TextCommentFragment;
161+
export default memo(TextCommentFragment);

0 commit comments

Comments
 (0)