From 67195245c112cceaadfeca290787e3678b44f150 Mon Sep 17 00:00:00 2001 From: takaion <3522531+takaion@users.noreply.github.com> Date: Sat, 11 May 2024 00:44:17 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20Unicode=E7=B5=B5=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=81=A8=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E7=B5=B5?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=81=AE=E5=90=8D=E5=89=8D=E3=81=8C=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E3=82=AB?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=A0=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=8C?= =?UTF-8?q?=E3=82=AA=E3=83=BC=E3=83=88=E3=82=B3=E3=83=B3=E3=83=97=E3=83=AA?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AB=E3=82=B5=E3=82=B8=E3=82=A7=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + packages/frontend/src/scripts/search-emoji.ts | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d95ea3fc38..b9b6938407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ - Fix: リバーシの対局を正しく共有できないことがある問題を修正 - Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正 - Fix: 連合なしの状態の読み書きができない問題を修正 +- Fix: Unicode絵文字とカスタム絵文字の名前が重複したときにカスタム絵文字がオートコンプリートにサジェストされない問題を修正 ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/frontend/src/scripts/search-emoji.ts b/packages/frontend/src/scripts/search-emoji.ts index 371f69b9a7..32bc9b6f4d 100644 --- a/packages/frontend/src/scripts/search-emoji.ts +++ b/packages/frontend/src/scripts/search-emoji.ts @@ -25,7 +25,7 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) // 完全一致(エイリアスなし) emojiDb.some(x => { if (x.name === query && !x.aliasOf) { - matched.set(x.name, { emoji: x, score: query.length + 3 }); + matched.set(x.emoji, { emoji: x, score: query.length + 3 }); } return matched.size === max; }); @@ -33,8 +33,8 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) // 完全一致(エイリアス込み) if (matched.size < max) { emojiDb.some(x => { - if (x.name === query && !matched.has(x.aliasOf ?? x.name)) { - matched.set(x.aliasOf ?? x.name, { emoji: x, score: query.length + 2 }); + if (x.name === query && !matched.has(x.emoji)) { + matched.set(x.emoji, { emoji: x, score: query.length + 2 }); } return matched.size === max; }); @@ -43,8 +43,8 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) // 前方一致(エイリアスなし) if (matched.size < max) { emojiDb.some(x => { - if (x.name.startsWith(query) && !x.aliasOf && !matched.has(x.name)) { - matched.set(x.name, { emoji: x, score: query.length + 1 }); + if (x.name.startsWith(query) && !x.aliasOf && !matched.has(x.emoji)) { + matched.set(x.emoji, { emoji: x, score: query.length + 1 }); } return matched.size === max; }); @@ -53,8 +53,8 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) // 前方一致(エイリアス込み) if (matched.size < max) { emojiDb.some(x => { - if (x.name.startsWith(query) && !matched.has(x.aliasOf ?? x.name)) { - matched.set(x.aliasOf ?? x.name, { emoji: x, score: query.length }); + if (x.name.startsWith(query) && !matched.has(x.emoji)) { + matched.set(x.emoji, { emoji: x, score: query.length }); } return matched.size === max; }); @@ -63,8 +63,8 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) // 部分一致(エイリアス込み) if (matched.size < max) { emojiDb.some(x => { - if (x.name.includes(query) && !matched.has(x.aliasOf ?? x.name)) { - matched.set(x.aliasOf ?? x.name, { emoji: x, score: query.length - 1 }); + if (x.name.includes(query) && !matched.has(x.emoji)) { + matched.set(x.emoji, { emoji: x, score: query.length - 1 }); } return matched.size === max; }); @@ -87,8 +87,8 @@ export function searchEmoji(query: string | null, emojiDb: EmojiDef[], max = 30) } // 半分以上の文字が含まれていればヒットとする - if (hit > Math.ceil(queryChars.length / 2) && hit - 2 > (matched.get(x.aliasOf ?? x.name)?.score ?? 0)) { - hitEmojis.set(x.aliasOf ?? x.name, { emoji: x, score: hit - 2 }); + if (hit > Math.ceil(queryChars.length / 2) && hit - 2 > (matched.get(x.emoji)?.score ?? 0)) { + hitEmojis.set(x.emoji, { emoji: x, score: hit - 2 }); } }