chore(git): merge pull request #103 from 96-nsfw-list-tag into staging
All checks were successful
Release to Staging / build_and_release (push) Successful in 45s

Reviewed-on: #103
This commit is contained in:
enes 2024-10-28 13:02:54 +00:00
commit f2f80a36c6
2 changed files with 21 additions and 3 deletions

View File

@ -22,6 +22,15 @@ export const useFilteredMods = (
) => { ) => {
return useMemo(() => { return useMemo(() => {
const nsfwFilter = (mods: ModDetails[]) => { const nsfwFilter = (mods: ModDetails[]) => {
// Add nsfw tag to mods included in nsfwList
if (filterOptions.nsfw !== NSFWFilter.Hide_NSFW) {
mods = mods.map((mod) => {
return !mod.nsfw && nsfwList.includes(mod.aTag)
? { ...mod, nsfw: true }
: mod
})
}
// Determine the filtering logic based on the NSFW filter option // Determine the filtering logic based on the NSFW filter option
switch (filterOptions.nsfw) { switch (filterOptions.nsfw) {
case NSFWFilter.Hide_NSFW: case NSFWFilter.Hide_NSFW:

View File

@ -15,7 +15,8 @@ import {
useAppSelector, useAppSelector,
useBodyScrollDisable, useBodyScrollDisable,
useDidMount, useDidMount,
useNDKContext useNDKContext,
useNSFWList
} from '../../hooks' } from '../../hooks'
import { getGamePageRoute, getModsEditPageRoute } from '../../routes' import { getGamePageRoute, getModsEditPageRoute } from '../../routes'
import '../../styles/comments.css' import '../../styles/comments.css'
@ -51,10 +52,18 @@ import placeholder from '../../assets/img/DEGMods Placeholder Img.png'
export const ModPage = () => { export const ModPage = () => {
const { naddr } = useParams() const { naddr } = useParams()
const { fetchEvent } = useNDKContext() const { fetchEvent } = useNDKContext()
const [modData, setModData] = useState<ModDetails>() const [mod, setMod] = useState<ModDetails>()
const [isFetching, setIsFetching] = useState(true) const [isFetching, setIsFetching] = useState(true)
const [commentCount, setCommentCount] = useState(0) 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 () => { useDidMount(async () => {
if (naddr) { if (naddr) {
const decoded = nip19.decode<'naddr'>(naddr as `naddr1${string}`) const decoded = nip19.decode<'naddr'>(naddr as `naddr1${string}`)
@ -70,7 +79,7 @@ export const ModPage = () => {
.then((event) => { .then((event) => {
if (event) { if (event) {
const extracted = extractModData(event) const extracted = extractModData(event)
setModData(extracted) setMod(extracted)
} }
}) })
.catch((err) => { .catch((err) => {