Skip to content

Commit

Permalink
Allow removing of custom emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 4, 2023
1 parent 32392a9 commit d8ad1d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.5.9",
"version": "4.5.13",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GetEmojiUrl } from '../components/emoji/BaseEmojiProps';
import {
addCustomEmojis,
setCustomEmojis,
emojiUrlByUnified
} from '../dataUtils/emojiSelectors';
import {
Expand Down Expand Up @@ -45,7 +45,7 @@ export function mergeConfig(
suggestionMode: config.suggestedEmojisMode
});

addCustomEmojis(config.customEmojis ?? []);
setCustomEmojis(config.customEmojis ?? []);

const skinTonePickerLocation = config.searchDisabled
? SkinTonePickerLocation.PREVIEW
Expand Down
7 changes: 5 additions & 2 deletions src/dataUtils/emojiSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down

0 comments on commit d8ad1d4

Please sign in to comment.