Use for loop and refactor lookup code

release
Peder Johnsen 2019-03-23 21:14:52 +00:00
parent 90b36d829f
commit 5c64cc6908
1 changed files with 10 additions and 6 deletions

View File

@ -157,19 +157,23 @@ function getEmojiDataFromNative(nativeString, set, data) {
} }
}) })
const emojiData = Object.values(data.emojis).find((emoji) => { let emojiData;
emoji = JSON.parse(_JSON.stringify(emoji))
for (let id in data.emojis) {
let emoji = data.emojis[id]
let emojiUnified = emoji.unified
if (emoji.variations && emoji.variations.length) { if (emoji.variations && emoji.variations.length) {
emoji.unified = emoji.variations.shift() emojiUnified = emoji.variations.shift()
} }
if (skin && emoji.skin_variations && emoji.skin_variations[skinCode]) { if (skin && emoji.skin_variations && emoji.skin_variations[skinCode]) {
emoji.unified = emoji.skin_variations[skinCode].unified emojiUnified = emoji.skin_variations[skinCode].unified
} }
return unifiedToNative(emoji.unified) === baseNativeString if (unifiedToNative(emojiUnified) === baseNativeString) emojiData = emoji
}) }
if (!emojiData) { if (!emojiData) {
return null return null