From 0b1d43eac416bc0f5c2fcc2192ce731fd3d5147c Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 28 Oct 2024 13:46:46 +0100 Subject: [PATCH 1/2] fix(mod-page): mark mod as nsfw if found in nsfwList --- src/pages/mod/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/mod/index.tsx b/src/pages/mod/index.tsx index 0f2e87c..5aa9bf9 100644 --- a/src/pages/mod/index.tsx +++ b/src/pages/mod/index.tsx @@ -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() + const [mod, setMod] = useState() 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) => { From 4f4e3a7c855eefb3dcd4a3e491e528b636020172 Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 28 Oct 2024 14:00:44 +0100 Subject: [PATCH 2/2] fix(mod-card): add nsfw tag if mod is in nsfwList, while filtering --- src/hooks/useFilteredMods.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hooks/useFilteredMods.ts b/src/hooks/useFilteredMods.ts index b067beb..7514be7 100644 --- a/src/hooks/useFilteredMods.ts +++ b/src/hooks/useFilteredMods.ts @@ -22,6 +22,15 @@ export const useFilteredMods = ( ) => { return useMemo(() => { 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 switch (filterOptions.nsfw) { case NSFWFilter.Hide_NSFW: