diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2020-02-19 22:06:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-19 22:06:54 +0900 |
| commit | e6c9b1d9bdd64270149cac3c8d0881d04b3edf7e (patch) | |
| tree | 0c7c6c0e2c81ea60b61b27f4d4ea9a3f0f1271f7 /src/misc | |
| parent | Update index.home.vue (diff) | |
| download | sharkey-e6c9b1d9bdd64270149cac3c8d0881d04b3edf7e.tar.gz sharkey-e6c9b1d9bdd64270149cac3c8d0881d04b3edf7e.tar.bz2 sharkey-e6c9b1d9bdd64270149cac3c8d0881d04b3edf7e.zip | |
LegacyReaction変換にstarを追加 (#6013)
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/reaction-lib.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/misc/reaction-lib.ts b/src/misc/reaction-lib.ts index c525d89385..43dbe1cc2c 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<string, string> = { +const legacies: Record<string, string> = { 'like': '👍', 'love': '❤', // ここに記述する場合は異体字セレクタを入れない 'laugh': '😆', @@ -13,6 +13,7 @@ const legacy10: Record<string, string> = { 'confused': '😥', 'rip': '😇', 'pudding': '🍮', + 'star': '⭐', }; export async function getFallbackReaction(): Promise<string> { @@ -24,11 +25,11 @@ export function convertLegacyReactions(reactions: Record<string, number>) { const _reactions = {} as Record<string, number>; 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<string> { 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<string> { } 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; } |