Repository navigation
Only add the new emojis to the frequent emojis list by doing a difference between former and new emojis #27687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
45f2936
b5e44b8
597f67b
093300e
fa0a82b
c2b8837
0bc8fa6
77a4d48
218905a
90e5225
932029f
f9c43fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,8 +102,14 @@ function ReportActionItemMessageEdit(props) { | |
| const length = getInitialDraft().length; | ||
| return {start: length, end: length}; | ||
| }; | ||
|
|
||
| const [draft, setDraft] = useState(() => getInitialDraft()); | ||
| const emojisPresentBefore = useRef([]); | ||
| const [draft, setDraft] = useState(() => { | ||
| const initialDraft = getInitialDraft(); | ||
| if (initialDraft) { | ||
| emojisPresentBefore.current = EmojiUtils.extractEmojis(initialDraft); | ||
| } | ||
| return initialDraft; | ||
| }); | ||
| const [selection, setSelection] = useState(getInitialSelection()); | ||
| const [isFocused, setIsFocused] = useState(false); | ||
| const [hasExceededMaxCommentLength, setHasExceededMaxCommentLength] = useState(false); | ||
|
|
@@ -200,9 +206,13 @@ function ReportActionItemMessageEdit(props) { | |
| const {text: newDraft, emojis} = EmojiUtils.replaceAndExtractEmojis(newDraftInput, props.preferredSkinTone, preferredLocale); | ||
|
|
||
| if (!_.isEmpty(emojis)) { | ||
| insertedEmojis.current = [...insertedEmojis.current, ...emojis]; | ||
| debouncedUpdateFrequentlyUsedEmojis(); | ||
| const newEmojis = EmojiUtils.getAddedEmojis(emojis, emojisPresentBefore.current); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this block to a util or an action? I can see the exact same thing repeated for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure how to do this cleanly with the debounce, also it was repeating before and a lot of code is repeating in those two files, can we keep it like this for now ? |
||
| if (!_.isEmpty(newEmojis)) { | ||
| insertedEmojis.current = [...insertedEmojis.current, ...newEmojis]; | ||
| debouncedUpdateFrequentlyUsedEmojis(); | ||
| } | ||
| } | ||
| emojisPresentBefore.current = emojis; | ||
| setDraft((prevDraft) => { | ||
| if (newDraftInput !== newDraft) { | ||
| const remainder = ComposerUtils.getCommonSuffixLength(prevDraft, newDraft); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't quite understand this part of the comment. Can you elaborate what do you mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that if we had 😏 before and now we have 😏😏😏 we need to return two 😏 even if 😏 was present in the former list