Browse Source

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

imwald
codytseng 1 year ago
parent
commit
ecd7e6d7db
  1. 2
      src/components/ParentNotePreview/index.tsx
  2. 3
      src/i18n/en.ts
  3. 3
      src/i18n/zh.ts
  4. 22
      src/pages/secondary/NotePage/index.tsx

2
src/components/ParentNotePreview/index.tsx

@ -54,7 +54,7 @@ export default function ParentNotePreview({ @@ -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} />
)}

3
src/i18n/en.ts

@ -182,6 +182,7 @@ export default { @@ -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'
}
}

3
src/i18n/zh.ts

@ -183,6 +183,7 @@ export default { @@ -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': '该用户已被屏蔽'
}
}

22
src/pages/secondary/NotePage/index.tsx

@ -17,6 +17,7 @@ import { kinds } from 'nostr-tools' @@ -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 @@ -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 }) { @@ -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

Loading…
Cancel
Save