From e6c9b1d9bdd64270149cac3c8d0881d04b3edf7e Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Wed, 19 Feb 2020 22:06:54 +0900 Subject: [PATCH] =?UTF-8?q?LegacyReaction=E5=A4=89=E6=8F=9B=E3=81=ABstar?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=20(#6013)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/misc/reaction-lib.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/misc/reaction-lib.ts b/src/misc/reaction-lib.ts index c525d8938..43dbe1cc2 100644 --- a/src/misc/reaction-lib.ts +++ b/src/misc/reaction-lib.ts @@ -2,7 +2,7 @@ import { emojiRegex } from './emoji-regex'; import { fetchMeta } from './fetch-meta'; import { Emojis } from '../models'; -const legacy10: Record = { +const legacies: Record = { 'like': '👍', 'love': '❤', // ここに記述する場合は異体字セレクタを入れない 'laugh': '😆', @@ -13,6 +13,7 @@ const legacy10: Record = { 'confused': '😥', 'rip': '😇', 'pudding': '🍮', + 'star': '⭐', }; export async function getFallbackReaction(): Promise { @@ -24,11 +25,11 @@ export function convertLegacyReactions(reactions: Record) { const _reactions = {} as Record; for (const reaction of Object.keys(reactions)) { - if (Object.keys(legacy10).includes(reaction)) { - if (_reactions[legacy10[reaction]]) { - _reactions[legacy10[reaction]] += reactions[reaction]; + if (Object.keys(legacies).includes(reaction)) { + if (_reactions[legacies[reaction]]) { + _reactions[legacies[reaction]] += reactions[reaction]; } else { - _reactions[legacy10[reaction]] = reactions[reaction]; + _reactions[legacies[reaction]] = reactions[reaction]; } } else { if (_reactions[reaction]) { @@ -46,7 +47,7 @@ export async function toDbReaction(reaction?: string | null): Promise { if (reaction == null) return await getFallbackReaction(); // 文字列タイプのリアクションを絵文字に変換 - if (Object.keys(legacy10).includes(reaction)) return legacy10[reaction]; + if (Object.keys(legacies).includes(reaction)) return legacies[reaction]; // Unicode絵文字 const match = emojiRegex.exec(reaction); @@ -72,6 +73,6 @@ export async function toDbReaction(reaction?: string | null): Promise { } export function convertLegacyReaction(reaction: string): string { - if (Object.keys(legacy10).includes(reaction)) return legacy10[reaction]; + if (Object.keys(legacies).includes(reaction)) return legacies[reaction]; return reaction; }