| @@ -101,7 +101,7 @@ import { isTouchUsing } from '@/scripts/touch'; | ||||
| import { deviceKind } from '@/scripts/device-kind'; | ||||
| import { i18n } from '@/i18n'; | ||||
| import { defaultStore } from '@/store'; | ||||
| import { customEmojiCategories, customEmojis } from '@/custom-emojis'; | ||||
| import { customEmojiCategories, customEmojis, customEmojisMap } from '@/custom-emojis'; | ||||
| import { $i } from '@/account'; | ||||
|  | ||||
| const props = withDefaults(defineProps<{ | ||||
| @@ -337,7 +337,7 @@ function done(query?: string): boolean | void { | ||||
| 	if (query == null || typeof query !== 'string') return; | ||||
|  | ||||
| 	const q2 = query.replace(/:/g, ''); | ||||
| 	const exactMatchCustom = customEmojis.value.find(emoji => emoji.name === q2); | ||||
| 	const exactMatchCustom = customEmojisMap.get(q2); | ||||
| 	if (exactMatchCustom) { | ||||
| 		chosen(exactMatchCustom); | ||||
| 		return true; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| import { computed } from 'vue'; | ||||
| import { getProxiedImageUrl, getStaticImageUrl } from '@/scripts/media-proxy'; | ||||
| import { defaultStore } from '@/store'; | ||||
| import { customEmojis } from '@/custom-emojis'; | ||||
| import { customEmojisMap } from '@/custom-emojis'; | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	name: string; | ||||
| @@ -26,7 +26,7 @@ const rawUrl = computed(() => { | ||||
| 		return props.url; | ||||
| 	} | ||||
| 	if (isLocal.value) { | ||||
| 		return customEmojis.value.find(x => x.name === customEmojiName.value)?.url ?? null; | ||||
| 		return customEmojisMap.get(customEmojiName.value)?.url ?? null; | ||||
| 	} | ||||
| 	return props.host ? `/emoji/${customEmojiName.value}@${props.host}.webp` : `/emoji/${customEmojiName.value}.webp`; | ||||
| }); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { shallowRef, computed, markRaw } from 'vue'; | ||||
| import { shallowRef, computed, markRaw, watch } from 'vue'; | ||||
| import * as Misskey from 'misskey-js'; | ||||
| import { api, apiGet } from './os'; | ||||
| import { useStream } from '@/stream'; | ||||
| @@ -16,6 +16,14 @@ export const customEmojiCategories = computed<[ ...string[], null ]>(() => { | ||||
| 	return markRaw([...Array.from(categories), null]); | ||||
| }); | ||||
|  | ||||
| export const customEmojisMap = new Map<string, Misskey.entities.CustomEmoji>(); | ||||
| watch(customEmojis, emojis => { | ||||
| 	customEmojisMap.clear(); | ||||
| 	for (const emoji of emojis) { | ||||
| 		customEmojisMap.set(emoji.name, emoji); | ||||
| 	} | ||||
| }, { immediate: true }); | ||||
|  | ||||
| // TODO: ここら辺副作用なのでいい感じにする | ||||
| const stream = useStream(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo