fix(mod-page): mark mod as nsfw if found in nsfwList
This commit is contained in:
parent
2dc0ab6cf4
commit
0b1d43eac4
@ -15,7 +15,8 @@ import {
|
||||
useAppSelector,
|
||||
useBodyScrollDisable,
|
||||
useDidMount,
|
||||
useNDKContext
|
||||
useNDKContext,
|
||||
useNSFWList
|
||||
} from '../../hooks'
|
||||
import { getGamePageRoute, getModsEditPageRoute } from '../../routes'
|
||||
import '../../styles/comments.css'
|
||||
@ -51,10 +52,18 @@ import placeholder from '../../assets/img/DEGMods Placeholder Img.png'
|
||||
export const ModPage = () => {
|
||||
const { naddr } = useParams()
|
||||
const { fetchEvent } = useNDKContext()
|
||||
const [modData, setModData] = useState<ModDetails>()
|
||||
const [mod, setMod] = useState<ModDetails>()
|
||||
const [isFetching, setIsFetching] = useState(true)
|
||||
const [commentCount, setCommentCount] = useState(0)
|
||||
|
||||
// Make sure to mark non-nsfw mods as NSFW if found in nsfwList
|
||||
const nsfwList = useNSFWList()
|
||||
const isMissingNsfwTag =
|
||||
!mod?.nsfw && mod?.aTag && nsfwList && nsfwList.includes(mod.aTag)
|
||||
const modData = isMissingNsfwTag
|
||||
? ({ ...mod, nsfw: true } as ModDetails)
|
||||
: mod
|
||||
|
||||
useDidMount(async () => {
|
||||
if (naddr) {
|
||||
const decoded = nip19.decode<'naddr'>(naddr as `naddr1${string}`)
|
||||
@ -70,7 +79,7 @@ export const ModPage = () => {
|
||||
.then((event) => {
|
||||
if (event) {
|
||||
const extracted = extractModData(event)
|
||||
setModData(extracted)
|
||||
setMod(extracted)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user