fix: hide the content of muted users' notes in the parent note preview

This commit is contained in:
codytseng
2025-02-25 23:18:12 +08:00
parent 2f9be97178
commit ecd7e6d7db
4 changed files with 27 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ export default function ParentNotePreview({
<div className="shrink-0">{t('reply to')}</div>
{event && <UserAvatar className="shrink-0" userId={event.pubkey} size="tiny" />}
{isMuted ? (
<div className="truncate">{t('[muted]')}</div>
<div className="truncate">[{t('This user has been muted')}]</div>
) : (
<ContentPreview className="truncate" event={event} />
)}

View File

@@ -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'
}
}

View File

@@ -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': '该用户已被屏蔽'
}
}

View File

@@ -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 (
<div>
<Card
className="flex space-x-1 p-1 items-center clickable text-sm text-muted-foreground hover:text-foreground"
onClick={() => push(toNote(eventId))}
>
<UserAvatar userId={event.pubkey} size="tiny" className="shrink-0" />
<SimpleUsername
userId={event.pubkey}
className="font-semibold truncate shrink-0"
skeletonClassName="h-3 shrink-0"
/>
<div>[{t('This user has been muted')}]</div>
</Card>
<div className="ml-5 w-px h-2 bg-border" />
</div>
)
}
return (
<div>
<Card