forked from srxl/akkoma-fe
feat/reorder-emojis-by-position-of-keyword
This commit is contained in:
parent
0c0722a092
commit
fee654f1ee
2 changed files with 18 additions and 6 deletions
|
@ -8,10 +8,17 @@ const LOAD_EMOJI_BY = 60
|
|||
const LOAD_EMOJI_MARGIN = 64
|
||||
|
||||
const filterByKeyword = (list, keyword = '') => {
|
||||
if (keyword === '') return list
|
||||
|
||||
const keywordLowercase = keyword.toLowerCase()
|
||||
return list.filter(emoji =>
|
||||
emoji.displayText.toLowerCase().includes(keywordLowercase)
|
||||
)
|
||||
const orderedEmojiList = []
|
||||
for (const emoji of list) {
|
||||
const indexOfKeyword = emoji.displayText.toLowerCase().indexOf( keywordLowercase )
|
||||
if ( indexOfKeyword > -1 ) {
|
||||
orderedEmojiList.splice(indexOfKeyword, 0, emoji)
|
||||
}
|
||||
}
|
||||
return orderedEmojiList
|
||||
}
|
||||
|
||||
const EmojiPicker = {
|
||||
|
|
|
@ -29,9 +29,14 @@ const ReactButton = {
|
|||
emojis () {
|
||||
if (this.filterWord !== '') {
|
||||
const filterWordLowercase = this.filterWord.toLowerCase()
|
||||
return this.$store.state.instance.emoji.filter(emoji =>
|
||||
emoji.displayText.toLowerCase().includes(filterWordLowercase)
|
||||
)
|
||||
const orderedEmojiList = []
|
||||
for (const emoji of this.$store.state.instance.emoji) {
|
||||
const indexOfFilterWord = emoji.displayText.toLowerCase().indexOf( filterWordLowercase )
|
||||
if ( indexOfFilterWord > -1 ) {
|
||||
orderedEmojiList.splice(indexOfFilterWord, 0, emoji)
|
||||
}
|
||||
}
|
||||
return orderedEmojiList
|
||||
}
|
||||
return this.$store.state.instance.emoji || []
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue