fix(client): use colorizeEmoji when unicodeEmojisMap.get
This commit is contained in:
parent
39d6af135f
commit
7565f7bec6
@ -114,6 +114,7 @@ import {
|
|||||||
unicodeEmojiCategories as categories,
|
unicodeEmojiCategories as categories,
|
||||||
getEmojiName,
|
getEmojiName,
|
||||||
CustomEmojiFolderTree,
|
CustomEmojiFolderTree,
|
||||||
|
getUnicodeEmoji,
|
||||||
} from '@/scripts/emojilist.js';
|
} from '@/scripts/emojilist.js';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
@ -382,7 +383,7 @@ function getDef(emoji: string) {
|
|||||||
if (emoji.includes(':')) {
|
if (emoji.includes(':')) {
|
||||||
return customEmojisMap.get(emoji.replace(/:/g, ''))!;
|
return customEmojisMap.get(emoji.replace(/:/g, ''))!;
|
||||||
} else {
|
} else {
|
||||||
return unicodeEmojisMap.get(emoji)!;
|
return getUnicodeEmoji(emoji)!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import { i18n } from '@/i18n.js';
|
|||||||
import * as sound from '@/scripts/sound.js';
|
import * as sound from '@/scripts/sound.js';
|
||||||
import { checkReactionPermissions } from '@/scripts/check-reaction-permissions.js';
|
import { checkReactionPermissions } from '@/scripts/check-reaction-permissions.js';
|
||||||
import { customEmojisMap } from '@/custom-emojis.js';
|
import { customEmojisMap } from '@/custom-emojis.js';
|
||||||
import { unicodeEmojisMap } from '@/scripts/emojilist.js';
|
import { getUnicodeEmoji, unicodeEmojisMap } from '@/scripts/emojilist.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
reaction: string;
|
reaction: string;
|
||||||
@ -52,7 +52,7 @@ const emit = defineEmits<{
|
|||||||
const buttonEl = shallowRef<HTMLElement>();
|
const buttonEl = shallowRef<HTMLElement>();
|
||||||
|
|
||||||
const emojiName = computed(() => props.reaction.replace(/:/g, '').replace(/@\./, ''));
|
const emojiName = computed(() => props.reaction.replace(/:/g, '').replace(/@\./, ''));
|
||||||
const emoji = computed(() => customEmojisMap.get(emojiName.value) ?? unicodeEmojisMap.get(props.reaction));
|
const emoji = computed(() => customEmojisMap.get(emojiName.value) ?? getUnicodeEmoji(props.reaction));
|
||||||
|
|
||||||
const canToggle = computed(() => {
|
const canToggle = computed(() => {
|
||||||
return !props.reaction.match(/@\w/) && $i && emoji.value && checkReactionPermissions($i, props.note, emoji.value);
|
return !props.reaction.match(/@\w/) && $i && emoji.value && checkReactionPermissions($i, props.note, emoji.value);
|
||||||
|
@ -21,7 +21,7 @@ export const emojilist: UnicodeEmojiDef[] = _emojilist.map(x => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const unicodeEmojisMap = new Map<string, UnicodeEmojiDef>(
|
export const unicodeEmojisMap = new Map<string, UnicodeEmojiDef>(
|
||||||
emojilist.map(x => [x.char, x])
|
emojilist.map(x => [x.char, x]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const _indexByChar = new Map<string, number>();
|
const _indexByChar = new Map<string, number>();
|
||||||
@ -39,6 +39,11 @@ for (let i = 0; i < emojilist.length; i++) {
|
|||||||
|
|
||||||
export const emojiCharByCategory = _charGroupByCategory;
|
export const emojiCharByCategory = _charGroupByCategory;
|
||||||
|
|
||||||
|
export function getUnicodeEmoji(char: string): UnicodeEmojiDef | null {
|
||||||
|
// Colorize it because emojilist.json assumes that
|
||||||
|
return unicodeEmojisMap.get(colorizeEmoji(char)) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
export function getEmojiName(char: string): string | null {
|
export function getEmojiName(char: string): string | null {
|
||||||
// Colorize it because emojilist.json assumes that
|
// Colorize it because emojilist.json assumes that
|
||||||
const idx = _indexByChar.get(colorizeEmoji(char));
|
const idx = _indexByChar.get(colorizeEmoji(char));
|
||||||
|
Loading…
Reference in New Issue
Block a user