feat: add NSFW display policy setting

This commit is contained in:
codytseng 2025-12-11 23:37:05 +08:00
parent c2b0e6f666
commit f6f974adc6
24 changed files with 185 additions and 53 deletions

View file

@ -1,5 +1,6 @@
import { Skeleton } from '@/components/ui/skeleton'
import { isMentioningMutedUsers } from '@/lib/event'
import { NSFW_DISPLAY_POLICY } from '@/constants'
import { isMentioningMutedUsers, isNsfwEvent } from '@/lib/event'
import { cn } from '@/lib/utils'
import { useContentPolicy } from '@/providers/ContentPolicyProvider'
import { useMuteList } from '@/providers/MuteListProvider'
@ -22,7 +23,7 @@ export default function NoteCard({
reposters?: string[]
}) {
const { mutePubkeySet } = useMuteList()
const { hideContentMentioningMutedUsers } = useContentPolicy()
const { hideContentMentioningMutedUsers, nsfwDisplayPolicy } = useContentPolicy()
const shouldHide = useMemo(() => {
if (filterMutedNotes && mutePubkeySet.has(event.pubkey)) {
return true
@ -30,8 +31,11 @@ export default function NoteCard({
if (hideContentMentioningMutedUsers && isMentioningMutedUsers(event, mutePubkeySet)) {
return true
}
if (nsfwDisplayPolicy === NSFW_DISPLAY_POLICY.HIDE && isNsfwEvent(event)) {
return true
}
return false
}, [event, filterMutedNotes, mutePubkeySet])
}, [event, filterMutedNotes, mutePubkeySet, nsfwDisplayPolicy])
if (shouldHide) return null
if (event.kind === kinds.Repost || event.kind === kinds.GenericRepost) {