diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2023-01-22 16:07:17 +0000 |
|---|---|---|
| committer | tamaina <tamaina@hotmail.co.jp> | 2023-01-22 16:07:17 +0000 |
| commit | d347f0a087747d4ae19255372ced2d69f62fc00d (patch) | |
| tree | d189d24fee2637eaf6e2cd70a08fa94ec6834907 /packages/frontend/src/components | |
| parent | :v: (diff) | |
| download | misskey-d347f0a087747d4ae19255372ced2d69f62fc00d.tar.gz misskey-d347f0a087747d4ae19255372ced2d69f62fc00d.tar.bz2 misskey-d347f0a087747d4ae19255372ced2d69f62fc00d.zip | |
wip
Diffstat (limited to 'packages/frontend/src/components')
| -rw-r--r-- | packages/frontend/src/components/global/MkEmoji.vue | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/frontend/src/components/global/MkEmoji.vue b/packages/frontend/src/components/global/MkEmoji.vue index 691392d732..5eba8764b1 100644 --- a/packages/frontend/src/components/global/MkEmoji.vue +++ b/packages/frontend/src/components/global/MkEmoji.vue @@ -1,6 +1,6 @@ <template> <span v-if="isCustom && errored">:{{ customEmojiName }}:</span> -<img v-else-if="isCustom" :class="[$style.root, $style.custom, { [$style.normal]: normal, [$style.noStyle]: noStyle }]" :src="url" :alt="alt" :title="alt" decoding="async" @error="errored = true"/> +<img v-else-if="isCustom" :class="[$style.root, $style.custom, { [$style.normal]: normal, [$style.noStyle]: noStyle }]" :src="url" :alt="alt" :title="alt" decoding="async" @error="errored = true" @load="errored = false"/> <img v-else-if="char && !useOsNativeEmojis" :class="$style.root" :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> @@ -25,29 +25,30 @@ const props = defineProps<{ const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath; const isCustom = computed(() => props.emoji.startsWith(':')); -const customEmojiName = props.emoji.substr(1, props.emoji.length - 2).replace('@.', ''); +const customEmojiName = computed(() => props.emoji.substr(1, props.emoji.length - 2).replace('@.', '')); const char = computed(() => isCustom.value ? undefined : props.emoji); const useOsNativeEmojis = computed(() => defaultStore.state.emojiStyle === 'native' && !props.isReaction); const url = computed(() => { if (char.value) { return char2path(char.value); - } else if (props.host == null && !customEmojiName.includes('@')) { - const found = customEmojis.value.find(x => x.name === customEmojiName); + } else if (props.host == null && !customEmojiName.value.includes('@')) { + const found = customEmojis.value.find(x => x.name === customEmojiName.value); + console.log(found) return found ? found.url : null; } else { - const rawUrl = props.host ? `/emoji/${customEmojiName}@${props.host}.webp` : `/emoji/${customEmojiName}.webp`; + const rawUrl = props.host ? `/emoji/${customEmojiName.value}@${props.host}.webp` : `/emoji/${customEmojiName.value}.webp`; return defaultStore.state.disableShowingAnimatedImages ? getStaticImageUrl(rawUrl) : rawUrl; } }); -const alt = computed(() => isCustom.value ? `:${customEmojiName}:` : char.value); +const alt = computed(() => isCustom.value ? `:${customEmojiName.value}:` : char.value); let errored = $ref(isCustom.value && url.value == null); // 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 = isCustom.value - ? `:${customEmojiName}:` + ? `:${customEmojiName.value}:` : (getEmojiName(char.value as string) ?? char.value as string); (event.target as HTMLElement).title = title; } |