From ecd7e6d7db62e9646d8f89ceaa18168b17bc0068 Mon Sep 17 00:00:00 2001 From: codytseng Date: Tue, 25 Feb 2025 23:18:12 +0800 Subject: [PATCH] fix: hide the content of muted users' notes in the parent note preview --- src/components/ParentNotePreview/index.tsx | 2 +- src/i18n/en.ts | 3 ++- src/i18n/zh.ts | 3 ++- src/pages/secondary/NotePage/index.tsx | 22 ++++++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/ParentNotePreview/index.tsx b/src/components/ParentNotePreview/index.tsx index 56f20c92..cb436beb 100644 --- a/src/components/ParentNotePreview/index.tsx +++ b/src/components/ParentNotePreview/index.tsx @@ -54,7 +54,7 @@ export default function ParentNotePreview({
{t('reply to')}
{event && } {isMuted ? ( -
{t('[muted]')}
+
[{t('This user has been muted')}]
) : ( )} diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 690cecdc..304c2e88 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -182,6 +182,7 @@ export default { 'Supported NIPs': 'Supported NIPs', 'Open in a': 'Open in {{a}}', 'Cannot handle event of kind k': 'Cannot handle event of kind {{k}}', - 'Sorry! The note cannot be found 😔': 'Sorry! The note cannot be found 😔' + 'Sorry! The note cannot be found 😔': 'Sorry! The note cannot be found 😔', + 'This user has been muted': 'This user has been muted' } } diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts index 4c76eb1c..e7f9e3dd 100644 --- a/src/i18n/zh.ts +++ b/src/i18n/zh.ts @@ -183,6 +183,7 @@ export default { 'Supported NIPs': '支持的 NIP', 'Open in a': '在 {{a}} 中打开', 'Cannot handle event of kind k': '无法处理类型为 {{k}} 的事件', - 'Sorry! The note cannot be found 😔': '抱歉!找不到该笔记 😔' + 'Sorry! The note cannot be found 😔': '抱歉!找不到该笔记 😔', + 'This user has been muted': '该用户已被屏蔽' } } diff --git a/src/pages/secondary/NotePage/index.tsx b/src/pages/secondary/NotePage/index.tsx index 9d884838..b71cb009 100644 --- a/src/pages/secondary/NotePage/index.tsx +++ b/src/pages/secondary/NotePage/index.tsx @@ -17,6 +17,7 @@ import { kinds } from 'nostr-tools' import { forwardRef, useMemo } from 'react' import { useTranslation } from 'react-i18next' import NotFoundPage from '../NotFoundPage' +import { useMuteList } from '@/providers/MuteListProvider' const NotePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref) => { const { t } = useTranslation() @@ -95,6 +96,7 @@ export default NotePage function ParentNote({ eventId }: { eventId?: string }) { const { t } = useTranslation() const { push } = useSecondaryPage() + const { mutePubkeys } = useMuteList() const { event, isFetching } = useFetchEvent(eventId) if (!eventId) return null @@ -126,6 +128,26 @@ function ParentNote({ eventId }: { eventId?: string }) { ) } + if (mutePubkeys.includes(event.pubkey)) { + return ( +
+ push(toNote(eventId))} + > + + +
[{t('This user has been muted')}]
+
+
+
+ ) + } + return (