Use variations at runtime instead of overriding data

Fixes a bug for emojis having both variations and skin variations
nolan/hinaloe-test
Etienne Lemay 2017-02-17 12:50:20 -05:00
parent ff0cc12fbc
commit f5ae64d07c
2 changed files with 9 additions and 4 deletions

View File

@ -32,10 +32,6 @@ emojiData.forEach((datum) => {
datum.name || (datum.name = datum.short_name.replace(/\-/g, ' ')) datum.name || (datum.name = datum.short_name.replace(/\-/g, ' '))
datum.name = inflection.titleize(datum.name || '') datum.name = inflection.titleize(datum.name || '')
if (datum.variations && datum.variations.length) {
datum.unified = datum.variations.shift()
}
if (datum.category == 'Flags') { if (datum.category == 'Flags') {
datum.name = datum.name.replace(/\s(\w+)$/, (letters) => letters.toUpperCase()) datum.name = datum.name.replace(/\s(\w+)$/, (letters) => letters.toUpperCase())
} }

View File

@ -75,6 +75,10 @@ function getData(emoji, skin, set) {
variationKey = `${emojiData.unified}-${skinKey}`, variationKey = `${emojiData.unified}-${skinKey}`,
variationData = emojiData.skin_variations[variationKey] variationData = emojiData.skin_variations[variationKey]
if (!variationData.variations && emojiData.variations) {
delete emojiData.variations
}
if (variationData[`has_img_${set}`]) { if (variationData[`has_img_${set}`]) {
emojiData.skin_tone = skin emojiData.skin_tone = skin
@ -85,6 +89,11 @@ function getData(emoji, skin, set) {
} }
} }
if (emojiData.variations && emojiData.variations.length) {
emojiData = JSON.parse(JSON.stringify(emojiData))
emojiData.unified = emojiData.variations.shift()
}
return emojiData return emojiData
} }