From d8ad1d4b75e5efe351207323ab683961d3206144 Mon Sep 17 00:00:00 2001 From: Evyatar Date: Sat, 4 Nov 2023 21:45:51 +0200 Subject: [PATCH] Allow removing of custom emojis --- package.json | 2 +- src/config/config.ts | 4 ++-- src/dataUtils/emojiSelectors.ts | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8f44623e..9ab3e780 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.5.9", + "version": "4.5.13", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/config/config.ts b/src/config/config.ts index cfce477a..0a6fe03f 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -1,6 +1,6 @@ import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps'; import { - addCustomEmojis, + setCustomEmojis, emojiUrlByUnified } from '../dataUtils/emojiSelectors'; import { @@ -45,7 +45,7 @@ export function mergeConfig( suggestionMode: config.suggestedEmojisMode }); - addCustomEmojis(config.customEmojis ?? []); + setCustomEmojis(config.customEmojis ?? []); const skinTonePickerLocation = config.searchDisabled ? SkinTonePickerLocation.PREVIEW diff --git a/src/dataUtils/emojiSelectors.ts b/src/dataUtils/emojiSelectors.ts index 6ffbc3e5..3b5c64e2 100644 --- a/src/dataUtils/emojiSelectors.ts +++ b/src/dataUtils/emojiSelectors.ts @@ -92,17 +92,20 @@ export function emojiByUnified(unified?: string): DataEmoji | undefined { export const allEmojis: DataEmojis = Object.values(emojis).flat(); -export function addCustomEmojis(customEmojis: CustomEmoji[]): void { +export function setCustomEmojis(customEmojis: CustomEmoji[]): void { + emojis[Categories.CUSTOM].length = 0; + customEmojis.forEach(emoji => { const emojiData = customToRegularEmoji(emoji); + emojis[Categories.CUSTOM].push(emojiData as never); + if (allEmojisByUnified[emojiData[EmojiProperties.unified]]) { return; } allEmojis.push(emojiData); allEmojisByUnified[emojiData[EmojiProperties.unified]] = emojiData; - emojis[Categories.CUSTOM].push(emojiData as never); indexEmoji(emojiData); }); }