summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/global
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-29 10:14:44 +0900
committerGitHub <noreply@github.com>2022-12-29 10:14:44 +0900
commit912791b3ab6a7cb6cbfda2aa9e15d95115770a5e (patch)
treee36053e09364ad0475fae453089eea455e29d71e /packages/frontend/src/components/global
parent:art: (diff)
downloadmisskey-912791b3ab6a7cb6cbfda2aa9e15d95115770a5e.tar.gz
misskey-912791b3ab6a7cb6cbfda2aa9e15d95115770a5e.tar.bz2
misskey-912791b3ab6a7cb6cbfda2aa9e15d95115770a5e.zip
refactor: 絵文字URLを引き回すのをやめる (#9423)
Diffstat (limited to 'packages/frontend/src/components/global')
-rw-r--r--packages/frontend/src/components/global/MkEmoji.vue16
-rw-r--r--packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.vue3
-rw-r--r--packages/frontend/src/components/global/MkUserName.vue2
3 files changed, 8 insertions, 13 deletions
diff --git a/packages/frontend/src/components/global/MkEmoji.vue b/packages/frontend/src/components/global/MkEmoji.vue
index ce1299a39f..9a8418758d 100644
--- a/packages/frontend/src/components/global/MkEmoji.vue
+++ b/packages/frontend/src/components/global/MkEmoji.vue
@@ -1,5 +1,5 @@
<template>
-<img v-if="customEmoji" class="mk-emoji custom" :class="{ normal, noStyle }" :src="url" :alt="alt" :title="alt" decoding="async"/>
+<img v-if="isCustom" class="mk-emoji custom" :class="{ normal, noStyle }" :src="url" :alt="alt" :title="alt" decoding="async"/>
<img v-else-if="char && !useOsNativeEmojis" class="mk-emoji" :src="url" :alt="alt" decoding="async" @pointerenter="computeTitle"/>
<span v-else-if="char && useOsNativeEmojis" :alt="alt" @pointerenter="computeTitle">{{ char }}</span>
<span v-else>{{ emoji }}</span>
@@ -7,44 +7,40 @@
<script lang="ts" setup>
import { computed } from 'vue';
-import { CustomEmoji } from 'misskey-js/built/entities';
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base';
import { defaultStore } from '@/store';
-import { instance } from '@/instance';
import { getEmojiName } from '@/scripts/emojilist';
const props = defineProps<{
emoji: string;
normal?: boolean;
noStyle?: boolean;
- customEmojis?: CustomEmoji[];
isReaction?: boolean;
}>();
const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath;
const isCustom = computed(() => props.emoji.startsWith(':'));
+const customEmojiName = props.emoji.substr(1, props.emoji.length - 2);
const char = computed(() => isCustom.value ? undefined : props.emoji);
const useOsNativeEmojis = computed(() => defaultStore.state.emojiStyle === 'native' && !props.isReaction);
-const ce = computed(() => props.customEmojis ?? instance.emojis ?? []);
-const customEmoji = computed(() => isCustom.value ? ce.value.find(x => x.name === props.emoji.substr(1, props.emoji.length - 2)) : undefined);
const url = computed(() => {
if (char.value) {
return char2path(char.value);
} else {
- const rawUrl = (customEmoji.value as CustomEmoji).url;
+ const rawUrl = '/emoji/' + customEmojiName + '.webp';
return defaultStore.state.disableShowingAnimatedImages
? getStaticImageUrl(rawUrl)
: rawUrl;
}
});
-const alt = computed(() => customEmoji.value ? `:${customEmoji.value.name}:` : char.value);
+const alt = computed(() => isCustom.value ? `:${customEmojiName}:` : char.value);
// Searching from an array with 2000 items for every emoji felt like too energy-consuming, so I decided to do it lazily on pointerenter
function computeTitle(event: PointerEvent): void {
- const title = customEmoji.value
- ? `:${customEmoji.value.name}:`
+ const title = isCustom.value
+ ? `:${customEmojiName}:`
: (getEmojiName(char.value as string) ?? char.value as string);
(event.target as HTMLElement).title = title;
}
diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.vue b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.vue
index 70d0108e9f..7b2ae03f59 100644
--- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.vue
+++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.vue
@@ -1,5 +1,5 @@
<template>
-<MfmCore :text="text" :plain="plain" :nowrap="nowrap" :author="author" :customEmojis="customEmojis" :isNote="isNote" class="havbbuyv" :class="{ nowrap }"/>
+<MfmCore :text="text" :plain="plain" :nowrap="nowrap" :author="author" :is-note="isNote" class="havbbuyv" :class="{ nowrap }"/>
</template>
<script lang="ts" setup>
@@ -11,7 +11,6 @@ const props = withDefaults(defineProps<{
plain?: boolean;
nowrap?: boolean;
author?: any;
- customEmojis?: any;
isNote?: boolean;
}>(), {
plain: false,
diff --git a/packages/frontend/src/components/global/MkUserName.vue b/packages/frontend/src/components/global/MkUserName.vue
index 090de3df30..c5fc61a182 100644
--- a/packages/frontend/src/components/global/MkUserName.vue
+++ b/packages/frontend/src/components/global/MkUserName.vue
@@ -1,5 +1,5 @@
<template>
-<Mfm :text="user.name || user.username" :plain="true" :nowrap="nowrap" :custom-emojis="user.emojis"/>
+<Mfm :text="user.name || user.username" :plain="true" :nowrap="nowrap"/>
</template>
<script lang="ts" setup>