2020-02-28 16:39:47 +00:00
|
|
|
import Popover from '../popover/popover.vue'
|
2020-10-19 16:38:49 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import { faSmileBeam } from '@fortawesome/free-regular-svg-icons'
|
|
|
|
|
|
|
|
library.add(faSmileBeam)
|
2019-11-15 14:29:25 +00:00
|
|
|
|
|
|
|
const ReactButton = {
|
2020-05-07 21:10:49 +00:00
|
|
|
props: ['status'],
|
2019-11-15 14:29:25 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2020-02-28 16:39:47 +00:00
|
|
|
filterWord: ''
|
2019-11-15 14:29:25 +00:00
|
|
|
}
|
|
|
|
},
|
2020-02-28 16:39:47 +00:00
|
|
|
components: {
|
|
|
|
Popover
|
|
|
|
},
|
2019-11-15 14:29:25 +00:00
|
|
|
methods: {
|
2020-02-28 16:39:47 +00:00
|
|
|
addReaction (event, emoji, close) {
|
2020-02-11 12:24:51 +00:00
|
|
|
const existingReaction = this.status.emoji_reactions.find(r => r.name === emoji)
|
|
|
|
if (existingReaction && existingReaction.me) {
|
|
|
|
this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji })
|
|
|
|
} else {
|
|
|
|
this.$store.dispatch('reactWithEmoji', { id: this.status.id, emoji })
|
|
|
|
}
|
2020-02-28 16:39:47 +00:00
|
|
|
close()
|
2021-02-25 15:27:29 +00:00
|
|
|
},
|
|
|
|
focusInput () {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const input = this.$el.querySelector('input')
|
|
|
|
if (input) input.focus()
|
|
|
|
})
|
2019-11-15 14:29:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2020-01-13 21:34:39 +00:00
|
|
|
commonEmojis () {
|
2020-11-28 13:27:58 +00:00
|
|
|
return [
|
|
|
|
{ displayText: 'thumbsup', replacement: '👍' },
|
|
|
|
{ displayText: 'angry', replacement: '😠' },
|
|
|
|
{ displayText: 'eyes', replacement: '👀' },
|
|
|
|
{ displayText: 'joy', replacement: '😂' },
|
|
|
|
{ displayText: 'fire', replacement: '🔥' }
|
|
|
|
]
|
2020-01-13 21:34:39 +00:00
|
|
|
},
|
2019-11-15 14:29:25 +00:00
|
|
|
emojis () {
|
2020-01-13 21:34:39 +00:00
|
|
|
if (this.filterWord !== '') {
|
2020-07-14 19:47:02 +00:00
|
|
|
const filterWordLowercase = this.filterWord.toLowerCase()
|
2020-09-21 16:10:55 +00:00
|
|
|
let orderedEmojiList = []
|
2020-09-21 15:29:36 +00:00
|
|
|
for (const emoji of this.$store.state.instance.emoji) {
|
2020-11-28 13:27:58 +00:00
|
|
|
if (emoji.replacement === this.filterWord) return [emoji]
|
|
|
|
|
2020-09-21 15:42:17 +00:00
|
|
|
const indexOfFilterWord = emoji.displayText.toLowerCase().indexOf(filterWordLowercase)
|
|
|
|
if (indexOfFilterWord > -1) {
|
2020-09-21 16:10:55 +00:00
|
|
|
if (!Array.isArray(orderedEmojiList[indexOfFilterWord])) {
|
|
|
|
orderedEmojiList[indexOfFilterWord] = []
|
|
|
|
}
|
|
|
|
orderedEmojiList[indexOfFilterWord].push(emoji)
|
2020-09-21 15:29:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-21 16:10:55 +00:00
|
|
|
return orderedEmojiList.flat()
|
2020-01-13 21:34:39 +00:00
|
|
|
}
|
2019-11-15 14:29:25 +00:00
|
|
|
return this.$store.state.instance.emoji || []
|
|
|
|
},
|
2020-09-29 10:18:37 +00:00
|
|
|
mergedConfig () {
|
|
|
|
return this.$store.getters.mergedConfig
|
|
|
|
}
|
2019-11-15 14:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ReactButton
|