mirror of
https://git.youjo.love/youjo/youjo-fe.git
synced 2024-11-20 13:59:55 +01:00
Merge branch 'feat/reorder-emojis-by-position-of-keyword' into 'develop'
feat/reorder-emojis-by-position-of-keyword See merge request pleroma/pleroma-fe!1240
This commit is contained in:
commit
0e14cd6102
2 changed files with 24 additions and 6 deletions
|
@ -8,10 +8,20 @@ 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 =>
|
let orderedEmojiList = []
|
||||||
emoji.displayText.toLowerCase().includes(keywordLowercase)
|
for (const emoji of list) {
|
||||||
)
|
const indexOfKeyword = emoji.displayText.toLowerCase().indexOf(keywordLowercase)
|
||||||
|
if (indexOfKeyword > -1) {
|
||||||
|
if (!Array.isArray(orderedEmojiList[indexOfKeyword])) {
|
||||||
|
orderedEmojiList[indexOfKeyword] = []
|
||||||
|
}
|
||||||
|
orderedEmojiList[indexOfKeyword].push(emoji)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return orderedEmojiList.flat()
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmojiPicker = {
|
const EmojiPicker = {
|
||||||
|
|
|
@ -28,9 +28,17 @@ 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 =>
|
let 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) {
|
||||||
|
if (!Array.isArray(orderedEmojiList[indexOfFilterWord])) {
|
||||||
|
orderedEmojiList[indexOfFilterWord] = []
|
||||||
|
}
|
||||||
|
orderedEmojiList[indexOfFilterWord].push(emoji)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return orderedEmojiList.flat()
|
||||||
}
|
}
|
||||||
return this.$store.state.instance.emoji || []
|
return this.$store.state.instance.emoji || []
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue