fix search not working, use computer property instead of state

This commit is contained in:
Henry Jameson 2019-11-08 20:12:01 +02:00
parent 0dcb696e26
commit a38d16273d

View file

@ -24,10 +24,8 @@ const EmojiPicker = {
showingStickers: false, showingStickers: false,
groupsScrolledClass: 'scrolled-top', groupsScrolledClass: 'scrolled-top',
keepOpen: false, keepOpen: false,
customEmojiBuffer: (this.$store.state.instance.customEmoji || []) customEmojiBufferSlice: LOAD_EMOJI_BY,
.slice(0, LOAD_EMOJI_BY),
customEmojiTimeout: null, customEmojiTimeout: null,
customEmojiCounter: LOAD_EMOJI_BY,
customEmojiLoadAllConfirmed: false customEmojiLoadAllConfirmed: false
} }
}, },
@ -81,32 +79,21 @@ const EmojiPicker = {
return return
} }
this.customEmojiBuffer.push( this.customEmojiBufferSlice += LOAD_EMOJI_BY
...this.filteredEmoji.slice(
this.customEmojiCounter,
this.customEmojiCounter + LOAD_EMOJI_BY
)
)
this.customEmojiTimeout = window.setTimeout(this.loadEmoji, LOAD_EMOJI_INTERVAL) this.customEmojiTimeout = window.setTimeout(this.loadEmoji, LOAD_EMOJI_INTERVAL)
this.customEmojiCounter += LOAD_EMOJI_BY
}, },
startEmojiLoad (forceUpdate = false) { startEmojiLoad (forceUpdate = false) {
const bufferSize = this.customEmojiBuffer.length const bufferSize = this.customEmojiBuffer.length
const bufferPrefilledSane = bufferSize === LOAD_EMOJI_SANE_AMOUNT && !this.customEmojiLoadAllConfirmed const bufferPrefilledSane = bufferSize === LOAD_EMOJI_SANE_AMOUNT && !this.customEmojiLoadAllConfirmed
const bufferPrefilledAll = bufferSize === this.filteredEmoji.length const bufferPrefilledAll = bufferSize === this.filteredEmoji.length
if (forceUpdate || bufferPrefilledSane || bufferPrefilledAll) { if ((bufferPrefilledSane || bufferPrefilledAll) && !forceUpdate) {
return return
} }
if (this.customEmojiTimeout) { if (this.customEmojiTimeout) {
window.clearTimeout(this.customEmojiTimeout) window.clearTimeout(this.customEmojiTimeout)
} }
set( this.customEmojiBufferSlice = LOAD_EMOJI_BY
this,
'customEmojiBuffer',
this.filteredEmoji.slice(0, LOAD_EMOJI_BY)
)
this.customEmojiCounter = LOAD_EMOJI_BY
this.customEmojiTimeout = window.setTimeout(this.loadEmoji, LOAD_EMOJI_INTERVAL) this.customEmojiTimeout = window.setTimeout(this.loadEmoji, LOAD_EMOJI_INTERVAL)
}, },
continueEmojiLoad () { continueEmojiLoad () {
@ -152,6 +139,9 @@ const EmojiPicker = {
this.keyword this.keyword
) )
}, },
customEmojiBuffer () {
return this.filteredEmoji.slice(0, this.customEmojiBufferSlice)
},
askForSanity () { askForSanity () {
return this.customEmojiBuffer.length >= LOAD_EMOJI_SANE_AMOUNT && return this.customEmojiBuffer.length >= LOAD_EMOJI_SANE_AMOUNT &&
!this.customEmojiLoadAllConfirmed !this.customEmojiLoadAllConfirmed