From 57505157f69bb0b9dc974225c2a593591dc17242 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Fri, 1 Mar 2024 22:21:59 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix(frontend):=20=E3=83=94=E3=83=B3?= =?UTF-8?q?=E7=95=99=E3=82=81=E3=81=AB=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=8C=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=81=A8=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E5=87=BA=E6=9D=A5=E3=81=AA=E3=81=8F=E3=81=AA=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkEmojiPicker.vue | 9 ++++++--- .../frontend/src/scripts/check-reaction-permissions.ts | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/frontend/src/components/MkEmojiPicker.vue b/packages/frontend/src/components/MkEmojiPicker.vue index 061afa66ac03..fd0b84facd84 100644 --- a/packages/frontend/src/components/MkEmojiPicker.vue +++ b/packages/frontend/src/components/MkEmojiPicker.vue @@ -353,7 +353,7 @@ watch(q, () => { searchResultUnicode.value = Array.from(searchUnicode()); }); -function canReact(emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef): boolean { +function canReact(emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef | string): boolean { return !props.targetNote || checkReactionPermissions($i!, props.targetNote, emoji); } @@ -378,9 +378,12 @@ function getKey(emoji: string | Misskey.entities.EmojiSimple | UnicodeEmojiDef): return typeof emoji === 'string' ? emoji : 'char' in emoji ? emoji.char : `:${emoji.name}:`; } -function getDef(emoji: string) { +function getDef(emoji: string): string | Misskey.entities.EmojiSimple | UnicodeEmojiDef { if (emoji.includes(':')) { - return customEmojisMap.get(emoji.replace(/:/g, ''))!; + // カスタム絵文字が存在する場合はその情報を持つオブジェクトを返し、 + // サーバの管理画面から削除された等で情報が見つからない場合は名前の文字列をそのまま返しておく(undefinedを返すとエラーになるため) + const name = emoji.replaceAll(':', ''); + return customEmojisMap.has(name) ? customEmojisMap.get(name)! : emoji; } else { return unicodeEmojisMap.get(emoji)!; } diff --git a/packages/frontend/src/scripts/check-reaction-permissions.ts b/packages/frontend/src/scripts/check-reaction-permissions.ts index da704717c127..b0fa7e4669f8 100644 --- a/packages/frontend/src/scripts/check-reaction-permissions.ts +++ b/packages/frontend/src/scripts/check-reaction-permissions.ts @@ -1,12 +1,12 @@ import * as Misskey from 'misskey-js'; import { UnicodeEmojiDef } from './emojilist.js'; -export function checkReactionPermissions(me: Misskey.entities.MeDetailed, note: Misskey.entities.Note, emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef): boolean { - if ('char' in emoji) return true; // UnicodeEmojiDefなら常にリアクション可能 +export function checkReactionPermissions(me: Misskey.entities.MeDetailed, note: Misskey.entities.Note, emoji: Misskey.entities.EmojiSimple | UnicodeEmojiDef | string): boolean { + if (typeof emoji === 'string') return false; + if ('char' in emoji) return true; // UnicodeEmojiDefなら常にリアクション可能 - emoji = emoji as Misskey.entities.EmojiSimple; - const roleIdsThatCanBeUsedThisEmojiAsReaction = emoji.roleIdsThatCanBeUsedThisEmojiAsReaction ?? []; - return !(emoji.localOnly && note.user.host !== me.host) + const roleIdsThatCanBeUsedThisEmojiAsReaction = emoji.roleIdsThatCanBeUsedThisEmojiAsReaction ?? []; + return !(emoji.localOnly && note.user.host !== me.host) && !(emoji.isSensitive && (note.reactionAcceptance === 'nonSensitiveOnly' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote')) && (roleIdsThatCanBeUsedThisEmojiAsReaction.length === 0 || me.roles.some(role => roleIdsThatCanBeUsedThisEmojiAsReaction.includes(role.id))); } From 2994a6806d33f5576d3688ebcb218bffa5e15c7a Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Fri, 1 Mar 2024 22:40:54 +0900 Subject: [PATCH 2/5] fix CHANGELOG.md --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15028e700868..4917f0b26c1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,17 @@ --> +## 202x.x.x (unreleased) + +### General +- + +### Client +- Fix: ピン留めされたリアクションがコントロールパネルより削除されていた際、リアクションデッキが表示できなくなる現象の修正 #13485 + +### Server +- + ## 2024.3.0 ### General From b976cb86120b39f92a9a813d1cce85f1f4571ad7 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Sat, 2 Mar 2024 09:35:08 +0900 Subject: [PATCH 3/5] fix Unicode Emojis --- CHANGELOG.md | 4 +++- packages/frontend/src/components/MkEmojiPicker.vue | 4 ++-- packages/frontend/src/scripts/emojilist.ts | 11 +++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4917f0b26c1a..6ce43b12d1f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,9 @@ - ### Client -- Fix: ピン留めされたリアクションがコントロールパネルより削除されていた際、リアクションデッキが表示できなくなる現象の修正 #13485 +- Fix: 絵文字関係の不具合を修正 (#13485) + - 履歴に残っている or ピン留めされた絵文字がコントロールパネルより削除されていた際にリアクションデッキが表示できなくなる + - Unicode絵文字が履歴に残っている or ピン留めされているとリアクションデッキが表示できなくなる ### Server - diff --git a/packages/frontend/src/components/MkEmojiPicker.vue b/packages/frontend/src/components/MkEmojiPicker.vue index e6e24b522564..a6b4f4273a58 100644 --- a/packages/frontend/src/components/MkEmojiPicker.vue +++ b/packages/frontend/src/components/MkEmojiPicker.vue @@ -383,9 +383,9 @@ function getDef(emoji: string): string | Misskey.entities.EmojiSimple | UnicodeE // カスタム絵文字が存在する場合はその情報を持つオブジェクトを返し、 // サーバの管理画面から削除された等で情報が見つからない場合は名前の文字列をそのまま返しておく(undefinedを返すとエラーになるため) const name = emoji.replaceAll(':', ''); - return customEmojisMap.has(name) ? customEmojisMap.get(name)! : emoji; + return customEmojisMap.get(name) ?? emoji; } else { - return getUnicodeEmoji(emoji)!; + return getUnicodeEmoji(emoji); } } diff --git a/packages/frontend/src/scripts/emojilist.ts b/packages/frontend/src/scripts/emojilist.ts index f2fbeae0ed08..242edcd38d23 100644 --- a/packages/frontend/src/scripts/emojilist.ts +++ b/packages/frontend/src/scripts/emojilist.ts @@ -39,9 +39,13 @@ for (let i = 0; i < emojilist.length; i++) { export const emojiCharByCategory = _charGroupByCategory; -export function getUnicodeEmoji(char: string): UnicodeEmojiDef | null { +export function getUnicodeEmoji(char: string): UnicodeEmojiDef | string { // Colorize it because emojilist.json assumes that - return unicodeEmojisMap.get(colorizeEmoji(char)) ?? null; + return unicodeEmojisMap.get(colorizeEmoji(char)) + // カラースタイル絵文字がjsonに無い場合はテキストスタイル絵文字にフォールバックする + ?? unicodeEmojisMap.get(char) + // それでも見つからない場合はそのまま返す + ?? char; } export function getEmojiName(char: string): string | null { @@ -54,6 +58,9 @@ export function getEmojiName(char: string): string | null { } } +/** + * テキストスタイル絵文字(U+260Eなどの1文字で表現される絵文字)をカラースタイル絵文字に変換します(VS16:U+FE0Fを付与)。 + */ export function colorizeEmoji(char: string) { return char.length === 1 ? `${char}\uFE0F` : char; } From b7a033e2c8f24d34742bea4f94a44dd7cabebf76 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Sat, 2 Mar 2024 10:51:06 +0900 Subject: [PATCH 4/5] fix Unicode Emojis --- packages/frontend/src/components/MkAutocomplete.vue | 2 +- .../frontend/src/components/MkEmojiPicker.section.vue | 2 +- packages/frontend/src/components/MkEmojiPicker.vue | 2 +- .../src/components/MkReactionsViewer.details.vue | 2 +- packages/frontend/src/components/global/MkEmoji.vue | 5 ++--- packages/frontend/src/scripts/emojilist.ts | 11 ++++++----- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index cae6bc711132..2f3855266cdc 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -77,7 +77,7 @@ const emojiDb = computed(() => { unicodeEmojiDB.push({ emoji: emoji, name: k, - aliasOf: getEmojiName(emoji)!, + aliasOf: getEmojiName(emoji), url: char2path(emoji), }); } diff --git a/packages/frontend/src/components/MkEmojiPicker.section.vue b/packages/frontend/src/components/MkEmojiPicker.section.vue index c295ab6bb7cd..012972d8ebdf 100644 --- a/packages/frontend/src/components/MkEmojiPicker.section.vue +++ b/packages/frontend/src/components/MkEmojiPicker.section.vue @@ -87,7 +87,7 @@ const shown = ref(!!props.initialShown); function computeButtonTitle(ev: MouseEvent): void { const elm = ev.target as HTMLElement; const emoji = elm.dataset.emoji as string; - elm.title = getEmojiName(emoji) ?? emoji; + elm.title = getEmojiName(emoji); } function nestedChosen(emoji: any, ev: MouseEvent) { diff --git a/packages/frontend/src/components/MkEmojiPicker.vue b/packages/frontend/src/components/MkEmojiPicker.vue index a6b4f4273a58..e30d5969d961 100644 --- a/packages/frontend/src/components/MkEmojiPicker.vue +++ b/packages/frontend/src/components/MkEmojiPicker.vue @@ -393,7 +393,7 @@ function getDef(emoji: string): string | Misskey.entities.EmojiSimple | UnicodeE function computeButtonTitle(ev: MouseEvent): void { const elm = ev.target as HTMLElement; const emoji = elm.dataset.emoji as string; - elm.title = getEmojiName(emoji) ?? emoji; + elm.title = getEmojiName(emoji); } function chosen(emoji: any, ev?: MouseEvent) { diff --git a/packages/frontend/src/components/MkReactionsViewer.details.vue b/packages/frontend/src/components/MkReactionsViewer.details.vue index 3158ba436e1e..8b5e6efdf3c6 100644 --- a/packages/frontend/src/components/MkReactionsViewer.details.vue +++ b/packages/frontend/src/components/MkReactionsViewer.details.vue @@ -44,7 +44,7 @@ function getReactionName(reaction: string): string { if (trimLocal.startsWith(':')) { return trimLocal; } - return getEmojiName(reaction) ?? reaction; + return getEmojiName(reaction); } diff --git a/packages/frontend/src/components/global/MkEmoji.vue b/packages/frontend/src/components/global/MkEmoji.vue index ba4026f0f649..65f75642b27a 100644 --- a/packages/frontend/src/components/global/MkEmoji.vue +++ b/packages/frontend/src/components/global/MkEmoji.vue @@ -10,7 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only