fix(notes): correctly mark repost as nsfw
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m12s

This commit is contained in:
en 2025-02-24 15:43:53 +01:00
parent bc5ad54ca9
commit 596e782b65

View File

@ -43,14 +43,18 @@ export const Note = ({ ndkEvent }: NoteProps) => {
filterKey, filterKey,
DEFAULT_FILTER_OPTIONS DEFAULT_FILTER_OPTIONS
) )
const isNsfw = ndkEvent
.getMatchingTags('L')
.some((t) => t[1] === 'content-warning')
const [repostEvent, setRepostEvent] = useState<NDKEvent | undefined>() const [repostEvent, setRepostEvent] = useState<NDKEvent | undefined>()
const [repostProfile, setRepostProfile] = useState<UserProfile | undefined>() const [repostProfile, setRepostProfile] = useState<UserProfile | undefined>()
const noteEvent = repostEvent ?? ndkEvent const noteEvent = repostEvent ?? ndkEvent
const isNsfw = noteEvent
.getMatchingTags('L')
.some((t) => t[1] === 'content-warning')
const noteProfile = repostProfile ?? eventProfile const noteProfile = repostProfile ?? eventProfile
const { commentEvents } = useComments(ndkEvent.pubkey, undefined, ndkEvent.id) const { commentEvents } = useComments(
noteEvent.pubkey,
undefined,
noteEvent.id
)
const [quoteRepostEvents, setQuoteRepostEvents] = useState<NDKEvent[]>([]) const [quoteRepostEvents, setQuoteRepostEvents] = useState<NDKEvent[]>([])
const [hasQuoted, setHasQuoted] = useState(false) const [hasQuoted, setHasQuoted] = useState(false)
const [repostEvents, setRepostEvents] = useState<NDKEvent[]>([]) const [repostEvents, setRepostEvents] = useState<NDKEvent[]>([])
@ -175,7 +179,7 @@ export const Note = ({ ndkEvent }: NoteProps) => {
// Cancel if not confirmed // Cancel if not confirmed
if (!confirm) return if (!confirm) return
const repostNdkEvent = await ndkEvent.repost(false) const repostNdkEvent = await noteEvent.repost(false)
const rawEvent = repostNdkEvent.rawEvent() const rawEvent = repostNdkEvent.rawEvent()
submit( submit(
JSON.stringify({ JSON.stringify({
@ -238,7 +242,7 @@ export const Note = ({ ndkEvent }: NoteProps) => {
</div> </div>
</div> </div>
<NsfwCommentWrapper <NsfwCommentWrapper
id={ndkEvent.id} id={noteEvent.id}
isNsfw={isNsfw} isNsfw={isNsfw}
hideNsfwActive={NSFWFilter.Hide_NSFW === filterOptions.nsfw} hideNsfwActive={NSFWFilter.Hide_NSFW === filterOptions.nsfw}
> >
@ -277,7 +281,7 @@ export const Note = ({ ndkEvent }: NoteProps) => {
</div> </div>
{showQuoteRepostPopup && ( {showQuoteRepostPopup && (
<NoteQuoteRepostPopup <NoteQuoteRepostPopup
ndkEvent={repostEvent || ndkEvent} ndkEvent={noteEvent}
handleClose={() => setShowQuoteRepostPopup(false)} handleClose={() => setShowQuoteRepostPopup(false)}
/> />
)} )}
@ -314,7 +318,7 @@ export const Note = ({ ndkEvent }: NoteProps) => {
)} )}
{showRepostPopup && ( {showRepostPopup && (
<NoteRepostPopup <NoteRepostPopup
ndkEvent={repostEvent || ndkEvent} ndkEvent={noteEvent}
handleConfirm={handleRepost} handleConfirm={handleRepost}
handleClose={() => setShowRepostPopup(false)} handleClose={() => setShowRepostPopup(false)}
/> />