nolan/hinaloe-test
Etienne Lemay 2017-04-04 12:00:32 -04:00
parent bb538ff9a3
commit 4926b7bd43
3 changed files with 25 additions and 21 deletions

View File

@ -103,7 +103,7 @@ emojiData.forEach((datum) => {
} }
}) })
var flags = data.categories[categoriesIndex['Flags']]; var flags = data.categories[categoriesIndex['Flags']]
flags.emojis.sort() flags.emojis.sort()
mkdirp('data', (err) => { mkdirp('data', (err) => {

View File

@ -12,7 +12,7 @@ import { Anchors, Category, Emoji, Preview, Search } from '.'
const RECENT_CATEGORY = { name: 'Recent', emojis: null } const RECENT_CATEGORY = { name: 'Recent', emojis: null }
const SEARCH_CATEGORY = { name: 'Search', emojis: null, anchor: RECENT_CATEGORY } const SEARCH_CATEGORY = { name: 'Search', emojis: null, anchor: RECENT_CATEGORY }
let CATEGORIES = []; let CATEGORIES = []
const I18N = { const I18N = {
search: 'Search', search: 'Search',
@ -40,35 +40,39 @@ export default class Picker extends React.Component {
firstRender: true, firstRender: true,
} }
let filteredCategories = []; let filteredCategories = []
for (let hash of data.categories) { for (let hash of data.categories) {
let isIncluded = props.include == undefined ? true : props.include.indexOf(hash.name.toLowerCase()) > -1 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 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) { for (let emoji of hash.emojis) {
let unified = data.emojis[emoji].unified; let unified = data.emojis[emoji].unified
if (props.emojisToShowFilter(unified)) { if (props.emojisToShowFilter(unified)) {
new_emojis.push(emoji) newEmojis.push(emoji)
} }
} }
if (new_emojis.length) { if (newEmojis.length) {
let new_hash = { let newHash = {
emojis: new_emojis, emojis: newEmojis,
name: hash.name name: hash.name,
} }
filteredCategories.push(new_hash);
filteredCategories.push(newHash)
} }
} }
CATEGORIES = [ CATEGORIES = [
SEARCH_CATEGORY, SEARCH_CATEGORY,
RECENT_CATEGORY, RECENT_CATEGORY,
].concat(filteredCategories); ].concat(filteredCategories)
this.categories = CATEGORIES; this.categories = CATEGORIES
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {

View File

@ -92,16 +92,16 @@ function search(value, emojisToShowFilter = () => true, maxResults = 75) {
} }
} }
let filtered_results = null; let filteredResults = null
if (results) { if (results) {
filtered_results = results.filter( filteredResults = results.filter((result) => emojisToShowFilter(data.emojis[result.id].unified))
(result) => emojisToShowFilter(data.emojis[result.id].unified)); if (filteredResults && filteredResults.length) {
if (filtered_results && filtered_results.length) { filteredResults = filteredResults.slice(0, maxResults)
filtered_results = filtered_results.slice(0, maxResults) }
}
} }
return filtered_results return filteredResults
} }
export default { search, emojis: emojisList, emoticons: emoticonsList } export default { search, emojis: emojisList, emoticons: emoticonsList }