From 8c9356b9fd8278de6b9dfabe0b7cecb830e11892 Mon Sep 17 00:00:00 2001 From: floatingghost Date: Thu, 16 Jun 2022 11:41:08 +0000 Subject: [PATCH] Reuse the emoji picker for reactions (#7) Fixes #6 Co-authored-by: FloatingGhost Reviewed-on: http://akkoma.dev/AkkomaGang/pleroma-fe/pulls/7 --- .woodpecker.yml | 2 + src/components/react_button/react_button.js | 41 +++----------------- src/components/react_button/react_button.vue | 41 ++------------------ 3 files changed, 11 insertions(+), 73 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index c882fea9..e4e5e296 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -3,6 +3,7 @@ pipeline: when: event: - push + - pull_request image: node:16 commands: - yarn @@ -13,6 +14,7 @@ pipeline: when: event: - push + - pull_request image: node:16 commands: - apt update diff --git a/src/components/react_button/react_button.js b/src/components/react_button/react_button.js index 7531fbc8..d4d08d6f 100644 --- a/src/components/react_button/react_button.js +++ b/src/components/react_button/react_button.js @@ -1,4 +1,5 @@ import Popover from '../popover/popover.vue' +import EmojiPicker from '../emoji_picker/emoji_picker.vue' import { library } from '@fortawesome/fontawesome-svg-core' import { faSmileBeam } from '@fortawesome/free-regular-svg-icons' @@ -12,10 +13,12 @@ const ReactButton = { } }, components: { - Popover + Popover, + EmojiPicker }, methods: { - addReaction (event, emoji, close) { + addReaction (event, close) { + const emoji = event.insertion const existingReaction = this.status.emoji_reactions.find(r => r.name === emoji) if (existingReaction && existingReaction.me) { this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji }) @@ -32,40 +35,6 @@ const ReactButton = { } }, computed: { - commonEmojis () { - return [ - { displayText: 'thumbsup', replacement: '👍' }, - { displayText: 'angry', replacement: '😠' }, - { displayText: 'eyes', replacement: '👀' }, - { displayText: 'joy', replacement: '😂' }, - { displayText: 'fire', replacement: '🔥' } - ] - }, - emojis () { - if (this.filterWord !== '') { - const filterWordLowercase = this.filterWord.toLowerCase() - let orderedEmojiList = [] - for (const emoji of [ - ...this.$store.state.instance.emoji, - ...this.$store.state.instance.customEmoji - ]) { - if (emoji.replacement === this.filterWord) return [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, - ...this.$store.state.instance.customEmoji - ] || [] - }, mergedConfig () { return this.$store.getters.mergedConfig } diff --git a/src/components/react_button/react_button.vue b/src/components/react_button/react_button.vue index e5103fb9..cc94f2fa 100644 --- a/src/components/react_button/react_button.vue +++ b/src/components/react_button/react_button.vue @@ -9,43 +9,10 @@ @show="focusInput" >