forked from AkkomaGang/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 LOAD_EMOJI_MARGIN = 64
|
||||||
|
|
||||||
const filterByKeyword = (list, keyword = '') => {
|
const filterByKeyword = (list, keyword = '') => {
|
||||||
|
if (keyword === '') return list
|
||||||
|
|
||||||
const keywordLowercase = keyword.toLowerCase()
|
const keywordLowercase = keyword.toLowerCase()
|
||||||
return list.filter(emoji =>
|
const orderedEmojiList = []
|
||||||
emoji.displayText.toLowerCase().includes(keywordLowercase)
|
for (const emoji of list) {
|
||||||
)
|
const indexOfKeyword = emoji.displayText.toLowerCase().indexOf( keywordLowercase )
|
||||||
|
if ( indexOfKeyword > -1 ) {
|
||||||
|
orderedEmojiList.splice(indexOfKeyword, 0, emoji)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return orderedEmojiList
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmojiPicker = {
|
const EmojiPicker = {
|
||||||
|
|
|
@ -29,9 +29,14 @@ const ReactButton = {
|
||||||
emojis () {
|
emojis () {
|
||||||
if (this.filterWord !== '') {
|
if (this.filterWord !== '') {
|
||||||
const filterWordLowercase = this.filterWord.toLowerCase()
|
const filterWordLowercase = this.filterWord.toLowerCase()
|
||||||
return this.$store.state.instance.emoji.filter(emoji =>
|
const orderedEmojiList = []
|
||||||
emoji.displayText.toLowerCase().includes(filterWordLowercase)
|
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 || []
|
return this.$store.state.instance.emoji || []
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue