Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): Unicode絵文字とカスタム絵文字の名前が重複したときにカスタム絵文字がオートコンプリートにサジェストされない問題を修正 #13817

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fix: 設定変更時のリロード確認ダイアログが複数個表示されることがある問題を修正
- Fix: ファイルの詳細ページのファイルの説明で改行が正しく表示されない問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/bde6bb0bd2e8b0d027e724d2acdb8ae0585a8110)
- Fix: Unicode絵文字とカスタム絵文字の名前が重複したときにカスタム絵文字がオートコンプリートにサジェストされない問題を修正

### Server
- Feat: Misskey® Reactions Buffering Technology™ (RBT)により、リアクションの作成負荷を低減することが可能に
Expand Down
22 changes: 11 additions & 11 deletions packages/frontend/src/scripts/search-emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ 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;
});

// 完全一致(エイリアス込み)
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;
});
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand All @@ -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 });
}
}

Expand Down
Loading