From c51428da6e94a98153fe51bce5447b8187449f8f Mon Sep 17 00:00:00 2001 From: Aparna Ananthakrishnan Date: Thu, 8 Feb 2024 14:31:35 -0500 Subject: [PATCH 1/2] Add custom frequently used emojis --- packages/emoji-mart/src/components/Picker/Picker.tsx | 2 +- packages/emoji-mart/src/components/Picker/PickerProps.ts | 1 + packages/emoji-mart/src/config.ts | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/emoji-mart/src/components/Picker/Picker.tsx b/packages/emoji-mart/src/components/Picker/Picker.tsx index 24cad2e6..b60f7857 100644 --- a/packages/emoji-mart/src/components/Picker/Picker.tsx +++ b/packages/emoji-mart/src/components/Picker/Picker.tsx @@ -625,7 +625,7 @@ export default class Picker extends Component { if (emoji) { const emojiData = getEmojiData(emoji, { skinIndex: this.state.skin - 1 }) - if (this.props.maxFrequentRows) { + if (!this.props.customFrequentlyUsed?.enabled && this.props.maxFrequentRows) { FrequentlyUsed.add(emojiData, this.props) } diff --git a/packages/emoji-mart/src/components/Picker/PickerProps.ts b/packages/emoji-mart/src/components/Picker/PickerProps.ts index 50eb7186..6f526dfc 100644 --- a/packages/emoji-mart/src/components/Picker/PickerProps.ts +++ b/packages/emoji-mart/src/components/Picker/PickerProps.ts @@ -105,6 +105,7 @@ export default { custom: null, data: null, i18n: null, + customFrequentlyUsed:{enabled: false, values: []}, // Callbacks getImageURL: null, diff --git a/packages/emoji-mart/src/config.ts b/packages/emoji-mart/src/config.ts index 725e3a38..f79a008d 100644 --- a/packages/emoji-mart/src/config.ts +++ b/packages/emoji-mart/src/config.ts @@ -145,7 +145,7 @@ async function _init(props) { const category = Data.categories[categoryIndex] if (category.id == 'frequent') { - let { maxFrequentRows, perLine } = props + let { maxFrequentRows, perLine, customFrequentlyUsed } = props maxFrequentRows = maxFrequentRows >= 0 @@ -153,7 +153,10 @@ async function _init(props) { : PickerProps.maxFrequentRows.value perLine || (perLine = PickerProps.perLine.value) - category.emojis = FrequentlyUsed.get({ maxFrequentRows, perLine }) + if(customFrequentlyUsed?.enabled) + category.emojis = customFrequentlyUsed.values + else + category.emojis = FrequentlyUsed.get({ maxFrequentRows, perLine }) } if (!category.emojis || !category.emojis.length) { From b5db4d31eaad35b838670c32a6c6977c5000b216 Mon Sep 17 00:00:00 2001 From: Aparna Ananthakrishnan Date: Fri, 9 Feb 2024 13:55:36 -0800 Subject: [PATCH 2/2] Prettier fixes --- packages/emoji-mart/src/components/Picker/Picker.tsx | 5 ++++- packages/emoji-mart/src/components/Picker/PickerProps.ts | 2 +- packages/emoji-mart/src/config.ts | 5 ++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/emoji-mart/src/components/Picker/Picker.tsx b/packages/emoji-mart/src/components/Picker/Picker.tsx index b60f7857..ffdfd8fd 100644 --- a/packages/emoji-mart/src/components/Picker/Picker.tsx +++ b/packages/emoji-mart/src/components/Picker/Picker.tsx @@ -625,7 +625,10 @@ export default class Picker extends Component { if (emoji) { const emojiData = getEmojiData(emoji, { skinIndex: this.state.skin - 1 }) - if (!this.props.customFrequentlyUsed?.enabled && this.props.maxFrequentRows) { + if ( + !this.props.customFrequentlyUsed?.enabled && + this.props.maxFrequentRows + ) { FrequentlyUsed.add(emojiData, this.props) } diff --git a/packages/emoji-mart/src/components/Picker/PickerProps.ts b/packages/emoji-mart/src/components/Picker/PickerProps.ts index 6f526dfc..0ea80f93 100644 --- a/packages/emoji-mart/src/components/Picker/PickerProps.ts +++ b/packages/emoji-mart/src/components/Picker/PickerProps.ts @@ -105,7 +105,7 @@ export default { custom: null, data: null, i18n: null, - customFrequentlyUsed:{enabled: false, values: []}, + customFrequentlyUsed: { enabled: false, values: [] }, // Callbacks getImageURL: null, diff --git a/packages/emoji-mart/src/config.ts b/packages/emoji-mart/src/config.ts index f79a008d..663f20fb 100644 --- a/packages/emoji-mart/src/config.ts +++ b/packages/emoji-mart/src/config.ts @@ -153,10 +153,9 @@ async function _init(props) { : PickerProps.maxFrequentRows.value perLine || (perLine = PickerProps.perLine.value) - if(customFrequentlyUsed?.enabled) + if (customFrequentlyUsed?.enabled) category.emojis = customFrequentlyUsed.values - else - category.emojis = FrequentlyUsed.get({ maxFrequentRows, perLine }) + else category.emojis = FrequentlyUsed.get({ maxFrequentRows, perLine }) } if (!category.emojis || !category.emojis.length) {