diff options
| author | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2018-11-05 16:19:10 +0900 |
|---|---|---|
| committer | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2018-11-05 16:19:14 +0900 |
| commit | 31b7626d018f3e241ddeac5b723c18fa41088bf5 (patch) | |
| tree | ea354969f1490f8709b7e439cff3b98835583115 /src/client | |
| parent | Add support for unicode emojis (diff) | |
| download | misskey-31b7626d018f3e241ddeac5b723c18fa41088bf5.tar.gz misskey-31b7626d018f3e241ddeac5b723c18fa41088bf5.tar.bz2 misskey-31b7626d018f3e241ddeac5b723c18fa41088bf5.zip | |
Make code better
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171423739
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171424596
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171425303
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/common/views/components/emoji.vue | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/app/common/views/components/emoji.vue b/src/client/app/common/views/components/emoji.vue index 2dca8fdcb5..6a078e023d 100644 --- a/src/client/app/common/views/components/emoji.vue +++ b/src/client/app/common/views/components/emoji.vue @@ -5,6 +5,11 @@ <script lang="ts"> import Vue from 'vue'; import { lib } from 'emojilib'; + +const findCustomEmoji = (x, emoji) => + x.name === emoji || + x.aliases && x.aliases.includes(emoji); + export default Vue.extend({ props: { emoji: { @@ -33,7 +38,8 @@ export default Vue.extend({ exec() { const { emoji, raw, customEmojis } = this; this.name = emoji || raw; - this.url = !raw && customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null; + if (!raw && customEmojis && customEmojis.length) + this.url = customEmojis.find(x => findCustomEmoji(x, emoji)).url; if (!this.url) { const char = raw || lib[emoji] && lib[emoji].char; if (char) { |