Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Merge branch 'trungtin-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Aug 17, 2016
2 parents 7db9f16 + a6845b2 commit ec54ce8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dialog"
],
"dependencies": {
"emojione": "^2.1.4",
"emojione": "^2.2.6",
"lodash": "^4.15.0",
"store": "^1.3.20"
},
Expand Down
14 changes: 10 additions & 4 deletions src/picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,24 @@ const Picker = React.createClass({
const emojis = {};

// categorise and nest emoji
// TODO: this could be done as a preprocess.
for (const key in strategy) {
// sort ensures that modifiers appear unmodified keys
const keys = Object.keys(strategy);
for (const key of keys) {
const value = strategy[key];

// skip unknown categories
if (value.category !== 'modifier') {
if (!emojis[value.category]) emojis[value.category] = {};
const match = key.match(/(.*?)_tone(.*?)$/);

// this does rely on the modifer emojis coming later in strategy
if (match) {
emojis[value.category][match[1]][match[2]] = value;
// this check is to stop the plugin from failing in the case that the
// emoji strategy miscategorizes tones - which was the case here:
// https://github.com/Ranks/emojione/pull/330
const unmodifiedEmojiExists = !!emojis[value.category][match[1]];
if (unmodifiedEmojiExists) {
emojis[value.category][match[1]][match[2]] = value;
}
} else {
emojis[value.category][key] = [value];
}
Expand Down

0 comments on commit ec54ce8

Please sign in to comment.