debounce emoji searching

This commit is contained in:
FloatingGhost 2023-08-04 16:48:13 +01:00
parent 856324fa26
commit 3b4208ea41
2 changed files with 5 additions and 14 deletions

View file

@ -7,7 +7,7 @@ import {
faStickyNote, faStickyNote,
faSmileBeam faSmileBeam
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
import { trim, escapeRegExp, startCase } from 'lodash' import { trim, escapeRegExp, startCase, debounce } from 'lodash'
library.add( library.add(
faBoxOpen, faBoxOpen,
@ -42,6 +42,9 @@ const EmojiPicker = {
EmojiGrid EmojiGrid
}, },
methods: { methods: {
debouncedSearch: debounce(function (e) {
this.keyword = e.target.value
}, 500),
onStickerUploaded (e) { onStickerUploaded (e) {
this.$emit('sticker-uploaded', e) this.$emit('sticker-uploaded', e)
}, },
@ -85,17 +88,6 @@ const EmojiPicker = {
activeGroupView () { activeGroupView () {
return this.showingStickers ? '' : this.activeGroup return this.showingStickers ? '' : this.activeGroup
}, },
stickersAvailable () {
if (this.$store.state.instance.stickers) {
return this.$store.state.instance.stickers.length > 0
}
return 0
},
filteredEmoji () {
return this.filterByKeyword(
this.$store.state.instance.customEmoji || []
)
},
emojis () { emojis () {
const recentEmojis = this.$store.getters.recentEmojis const recentEmojis = this.$store.getters.recentEmojis
const standardEmojis = this.$store.state.instance.emoji || [] const standardEmojis = this.$store.state.instance.emoji || []

View file

@ -44,11 +44,10 @@
> >
<div class="emoji-search"> <div class="emoji-search">
<input <input
v-model="keyword"
type="text" type="text"
class="form-control" class="form-control"
:placeholder="$t('emoji.search_emoji')" :placeholder="$t('emoji.search_emoji')"
@input="$event.target.composing = false" @input="debouncedSearch"
> >
</div> </div>
<EmojiGrid <EmojiGrid