From 4926b7bd43e86737edfcabb59407cbed437830d9 Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Tue, 4 Apr 2017 12:00:32 -0400 Subject: [PATCH] :lipstick: --- scripts/build-data.js | 2 +- src/components/picker.js | 30 +++++++++++++++++------------- src/utils/emoji-index.js | 14 +++++++------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/scripts/build-data.js b/scripts/build-data.js index 420b7c6..17cf63a 100644 --- a/scripts/build-data.js +++ b/scripts/build-data.js @@ -103,7 +103,7 @@ emojiData.forEach((datum) => { } }) -var flags = data.categories[categoriesIndex['Flags']]; +var flags = data.categories[categoriesIndex['Flags']] flags.emojis.sort() mkdirp('data', (err) => { diff --git a/src/components/picker.js b/src/components/picker.js index db8dcf5..90ff329 100644 --- a/src/components/picker.js +++ b/src/components/picker.js @@ -12,7 +12,7 @@ import { Anchors, Category, Emoji, Preview, Search } from '.' const RECENT_CATEGORY = { name: 'Recent', emojis: null } const SEARCH_CATEGORY = { name: 'Search', emojis: null, anchor: RECENT_CATEGORY } -let CATEGORIES = []; +let CATEGORIES = [] const I18N = { search: 'Search', @@ -40,35 +40,39 @@ export default class Picker extends React.Component { firstRender: true, } - let filteredCategories = []; + let filteredCategories = [] for (let hash of data.categories) { let isIncluded = props.include == undefined ? true : props.include.indexOf(hash.name.toLowerCase()) > -1 let isExcluded = props.exclude == undefined ? false : props.exclude.indexOf(hash.name.toLowerCase()) > -1 - if (!isIncluded || isExcluded) { continue; } + if (!isIncluded || isExcluded) { continue } + + let newEmojis = [] - let new_emojis = []; for (let emoji of hash.emojis) { - let unified = data.emojis[emoji].unified; + let unified = data.emojis[emoji].unified + if (props.emojisToShowFilter(unified)) { - new_emojis.push(emoji) + newEmojis.push(emoji) } } - if (new_emojis.length) { - let new_hash = { - emojis: new_emojis, - name: hash.name + if (newEmojis.length) { + let newHash = { + emojis: newEmojis, + name: hash.name, } - filteredCategories.push(new_hash); + + filteredCategories.push(newHash) } } + CATEGORIES = [ SEARCH_CATEGORY, RECENT_CATEGORY, - ].concat(filteredCategories); + ].concat(filteredCategories) - this.categories = CATEGORIES; + this.categories = CATEGORIES } componentWillReceiveProps(props) { diff --git a/src/utils/emoji-index.js b/src/utils/emoji-index.js index 7a97f47..e83ec3b 100644 --- a/src/utils/emoji-index.js +++ b/src/utils/emoji-index.js @@ -92,16 +92,16 @@ function search(value, emojisToShowFilter = () => true, maxResults = 75) { } } - let filtered_results = null; + let filteredResults = null + if (results) { - filtered_results = results.filter( - (result) => emojisToShowFilter(data.emojis[result.id].unified)); - if (filtered_results && filtered_results.length) { - filtered_results = filtered_results.slice(0, maxResults) - } + filteredResults = results.filter((result) => emojisToShowFilter(data.emojis[result.id].unified)) + if (filteredResults && filteredResults.length) { + filteredResults = filteredResults.slice(0, maxResults) + } } - return filtered_results + return filteredResults } export default { search, emojis: emojisList, emoticons: emoticonsList }