Compare commits
2 Commits
c1d226b4d4
...
7840c32d2b
Author | SHA1 | Date | |
---|---|---|---|
|
7840c32d2b | ||
|
440a2c6be1 |
@ -2,4 +2,5 @@ export * from './redux'
|
|||||||
export * from './useDidMount'
|
export * from './useDidMount'
|
||||||
export * from './useGames'
|
export * from './useGames'
|
||||||
export * from './useMuteLists'
|
export * from './useMuteLists'
|
||||||
|
export * from './useNSFWList'
|
||||||
export * from './useReactions'
|
export * from './useReactions'
|
||||||
|
17
src/hooks/useNSFWList.ts
Normal file
17
src/hooks/useNSFWList.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { MetadataController } from 'controllers'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useDidMount } from './useDidMount'
|
||||||
|
|
||||||
|
export const useNSFWList = () => {
|
||||||
|
const [nsfwList, setNSFWList] = useState<string[]>([])
|
||||||
|
|
||||||
|
useDidMount(async () => {
|
||||||
|
const metadataController = await MetadataController.getInstance()
|
||||||
|
|
||||||
|
metadataController.getNSFWList().then((list) => {
|
||||||
|
setNSFWList(list)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return nsfwList
|
||||||
|
}
|
@ -8,7 +8,7 @@ import { GameCard } from '../components/GameCard'
|
|||||||
import { ModCard } from '../components/ModCard'
|
import { ModCard } from '../components/ModCard'
|
||||||
import { LANDING_PAGE_DATA } from '../constants'
|
import { LANDING_PAGE_DATA } from '../constants'
|
||||||
import { RelayController } from '../controllers'
|
import { RelayController } from '../controllers'
|
||||||
import { useDidMount, useGames, useMuteLists } from '../hooks'
|
import { useDidMount, useGames, useMuteLists, useNSFWList } from '../hooks'
|
||||||
import { appRoutes, getModPageRoute } from '../routes'
|
import { appRoutes, getModPageRoute } from '../routes'
|
||||||
import { ModDetails } from '../types'
|
import { ModDetails } from '../types'
|
||||||
import {
|
import {
|
||||||
@ -259,6 +259,7 @@ const DisplayLatestMods = () => {
|
|||||||
const [latestMods, setLatestMods] = useState<ModDetails[]>([])
|
const [latestMods, setLatestMods] = useState<ModDetails[]>([])
|
||||||
|
|
||||||
const muteLists = useMuteLists()
|
const muteLists = useMuteLists()
|
||||||
|
const nsfwList = useNSFWList()
|
||||||
|
|
||||||
useDidMount(() => {
|
useDidMount(() => {
|
||||||
fetchMods({ source: window.location.host })
|
fetchMods({ source: window.location.host })
|
||||||
@ -280,11 +281,14 @@ const DisplayLatestMods = () => {
|
|||||||
|
|
||||||
const filtered = latestMods.filter(
|
const filtered = latestMods.filter(
|
||||||
(mod) =>
|
(mod) =>
|
||||||
!mutedAuthors.includes(mod.author) && !mutedEvents.includes(mod.aTag)
|
!mutedAuthors.includes(mod.author) &&
|
||||||
|
!mutedEvents.includes(mod.aTag) &&
|
||||||
|
!nsfwList.includes(mod.aTag) &&
|
||||||
|
!mod.nsfw
|
||||||
)
|
)
|
||||||
|
|
||||||
return filtered.slice(0, 4)
|
return filtered.slice(0, 4)
|
||||||
}, [muteLists, latestMods])
|
}, [muteLists, nsfwList, latestMods])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='IBMSecMain IBMSMListWrapper'>
|
<div className='IBMSecMain IBMSMListWrapper'>
|
||||||
|
@ -12,8 +12,7 @@ import { createSearchParams, useNavigate } from 'react-router-dom'
|
|||||||
import { LoadingSpinner } from '../components/LoadingSpinner'
|
import { LoadingSpinner } from '../components/LoadingSpinner'
|
||||||
import { ModCard } from '../components/ModCard'
|
import { ModCard } from '../components/ModCard'
|
||||||
import { MOD_FILTER_LIMIT } from '../constants'
|
import { MOD_FILTER_LIMIT } from '../constants'
|
||||||
import { MetadataController } from '../controllers'
|
import { useAppSelector, useMuteLists, useNSFWList } from '../hooks'
|
||||||
import { useAppSelector, useDidMount, useMuteLists } from '../hooks'
|
|
||||||
import { appRoutes } from '../routes'
|
import { appRoutes } from '../routes'
|
||||||
import '../styles/filters.css'
|
import '../styles/filters.css'
|
||||||
import '../styles/pagination.css'
|
import '../styles/pagination.css'
|
||||||
@ -58,21 +57,12 @@ export const ModsPage = () => {
|
|||||||
moderated: ModeratedFilter.Moderated
|
moderated: ModeratedFilter.Moderated
|
||||||
})
|
})
|
||||||
const muteLists = useMuteLists()
|
const muteLists = useMuteLists()
|
||||||
|
const nsfwList = useNSFWList()
|
||||||
const [nsfwList, setNSFWList] = useState<string[]>([])
|
|
||||||
|
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
|
|
||||||
const userState = useAppSelector((state) => state.user)
|
const userState = useAppSelector((state) => state.user)
|
||||||
|
|
||||||
useDidMount(async () => {
|
|
||||||
const metadataController = await MetadataController.getInstance()
|
|
||||||
|
|
||||||
metadataController.getNSFWList().then((list) => {
|
|
||||||
setNSFWList(list)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsFetching(true)
|
setIsFetching(true)
|
||||||
fetchMods({ source: filterOptions.source })
|
fetchMods({ source: filterOptions.source })
|
||||||
|
Loading…
Reference in New Issue
Block a user