From 98b0237efb917b65e32375c3f48ba13361f27fa5 Mon Sep 17 00:00:00 2001 From: mattyatea Date: Sat, 21 Sep 2024 14:10:55 +0900 Subject: [PATCH] =?UTF-8?q?Enhance:=20=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=83=9F=E3=83=A5=E3=83=BC=E3=83=88=E5=91=A8?= =?UTF-8?q?=E3=82=8A=E3=82=92=E6=94=B9=E4=BF=AE=20(#54)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 14 +++++++++++ locales/ja-JP.yml | 5 ++++ .../src/components/MkReactionsViewer.vue | 23 ++++++++++++++++--- .../pages/settings/mute-block.word-mute.vue | 1 + 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index e47e0ec94091..fe3691e29667 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -7824,6 +7824,20 @@ export interface Locale extends ILocale { */ "hideMutedNotes": string; }; + "_reactionMute": { + /** + * ミュートするリアクション + */ + "muteReactions": string; + /** + * 改行で区切って設定します + */ + "muteReactionsDescription": string; + /** + * リアクションの名前をスラッシュで囲むと正規表現になります。 + */ + "muteReactionsDescription2": string; + }; "_instanceMute": { /** * ミュートしたサーバーのユーザーへの返信を含めて、設定したサーバーの全てのノートとRenoteをミュートします。 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index bf411a0d6e5c..9ad4872b0b80 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2046,6 +2046,11 @@ _wordMute: muteWordsDescription2: "キーワードをスラッシュで囲むと正規表現になります。" hideMutedNotes: "ミュートされた単語を含むノートを非表示にする" +_reactionMute: + muteReactions: "ミュートするリアクション" + muteReactionsDescription: "改行で区切って設定します" + muteReactionsDescription2: "リアクションの名前をスラッシュで囲むと正規表現になります。" + _instanceMute: instanceMuteDescription: "ミュートしたサーバーのユーザーへの返信を含めて、設定したサーバーの全てのノートとRenoteをミュートします。" instanceMuteDescription2: "改行で区切って設定します" diff --git a/packages/frontend/src/components/MkReactionsViewer.vue b/packages/frontend/src/components/MkReactionsViewer.vue index 0d354ad21af0..fc1c10eda3ad 100644 --- a/packages/frontend/src/components/MkReactionsViewer.vue +++ b/packages/frontend/src/components/MkReactionsViewer.vue @@ -58,7 +58,16 @@ function onMockToggleReaction(emoji: string, count: number) { if ($i && reactions.value) { reactions.value = reactions.value.map(([reactionType, count]) => { - if (reactionType === props.note.myReaction || !($i.mutedReactions.flat()).includes(reactionType)) { + const isMuted = $i.mutedReactions.flat().some(mutedReaction => { + if (mutedReaction.startsWith('/') && mutedReaction.endsWith('/')) { + const regex = new RegExp(mutedReaction.slice(1, -1)); + return regex.test(reactionType); + } else { + return reactionType.includes(mutedReaction); + } + }); + + if (reactionType === props.note.myReaction || !isMuted) { return [reactionType, count]; } else { return ['🚮', count]; @@ -90,10 +99,18 @@ watch([() => props.note.reactions, () => props.maxNumber], ([newSource, maxNumbe } if ($i) { reactions.value = newReactions.map(([reactionType, count]) => { - if (reactionType === props.note.myReaction || !($i.mutedReactions.flat()).includes(reactionType)) { + const isMuted = $i.mutedReactions.flat().some(mutedReaction => { + if (mutedReaction.startsWith('/') && mutedReaction.endsWith('/')) { + const regex = new RegExp(mutedReaction.slice(1, -1)); + return regex.test(reactionType); + } else { + return reactionType.includes(mutedReaction); + } + }); + if (reactionType === props.note.myReaction || !isMuted) { return [reactionType, count]; } else { - return ['🚮️', count]; + return ['🚮', count]; } }); } else { diff --git a/packages/frontend/src/pages/settings/mute-block.word-mute.vue b/packages/frontend/src/pages/settings/mute-block.word-mute.vue index 16a00b8f86ef..2af72670da87 100644 --- a/packages/frontend/src/pages/settings/mute-block.word-mute.vue +++ b/packages/frontend/src/pages/settings/mute-block.word-mute.vue @@ -9,6 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts._wordMute.muteWords }} + {{ i18n.ts.save }}