feat: add toggle to show NSFW content by default

This commit is contained in:
codytseng 2025-08-14 22:56:44 +08:00
parent 352eecc416
commit cb2ad30b1d
23 changed files with 108 additions and 55 deletions

View file

@ -8,6 +8,7 @@ import {
isPictureEvent
} from '@/lib/event'
import { toNote } from '@/lib/link'
import { useContentPolicy } from '@/providers/ContentPolicyProvider'
import { useMuteList } from '@/providers/MuteListProvider'
import { useScreenSize } from '@/providers/ScreenSizeProvider'
import { Event, kinds } from 'nostr-tools'
@ -60,6 +61,7 @@ export default function Note({
[event]
)
const usingClient = useMemo(() => getUsingClient(event), [event])
const { defaultShowNsfw } = useContentPolicy()
const [showNsfw, setShowNsfw] = useState(false)
const { mutePubkeys } = useMuteList()
const [showMuted, setShowMuted] = useState(false)
@ -83,7 +85,7 @@ export default function Note({
content = <UnknownNote className="mt-2" event={event} />
} else if (mutePubkeys.includes(event.pubkey) && !showMuted) {
content = <MutedNote show={() => setShowMuted(true)} />
} else if (isNsfwEvent(event) && !showNsfw) {
} else if (!defaultShowNsfw && isNsfwEvent(event) && !showNsfw) {
content = <NsfwNote show={() => setShowNsfw(true)} />
} else if (event.kind === kinds.Highlights) {
content = <Highlight className="mt-2" event={event} />

View file

@ -1,10 +1,10 @@
import { cn, isInViewport } from '@/lib/utils'
import { useAutoplay } from '@/providers/AutoplayProvider'
import { useContentPolicy } from '@/providers/ContentPolicyProvider'
import mediaManager from '@/services/media-manager.service'
import { useEffect, useRef } from 'react'
export default function VideoPlayer({ src, className }: { src: string; className?: string }) {
const { autoplay } = useAutoplay()
const { autoplay } = useContentPolicy()
const videoRef = useRef<HTMLVideoElement>(null)
const containerRef = useRef<HTMLDivElement>(null)