diff --git a/src/components/ModForm.tsx b/src/components/ModForm.tsx index 982fc75..8be5ba8 100644 --- a/src/components/ModForm.tsx +++ b/src/components/ModForm.tsx @@ -60,7 +60,7 @@ export const ModForm = ({ existingModData }: ModFormProps) => { const [isPublishing, setIsPublishing] = useState(false) const [gameOptions, setGameOptions] = useState([]) const [formState, setFormState] = useState( - initializeFormState(existingModData) + initializeFormState() ) const [formErrors, setFormErrors] = useState({}) @@ -70,6 +70,12 @@ export const ModForm = ({ existingModData }: ModFormProps) => { } }, [location.pathname]) // Only trigger when the pathname changes to submit-mod + useEffect(() => { + if (existingModData) { + setFormState(initializeFormState(existingModData)) + } + }, [existingModData]) + useEffect(() => { const options = games.map((game) => ({ label: game['Game Name'], diff --git a/src/pages/home.tsx b/src/pages/home.tsx index f432d51..9b204dc 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -8,7 +8,7 @@ import { GameCard } from '../components/GameCard' import { ModCard } from '../components/ModCard' import { LANDING_PAGE_DATA } from '../constants' import { RelayController } from '../controllers' -import { useDidMount, useGames } from '../hooks' +import { useDidMount, useGames, useMuteLists } from '../hooks' import { appRoutes, getModPageRoute } from '../routes' import { ModDetails } from '../types' import { @@ -258,12 +258,12 @@ const DisplayLatestMods = () => { const [isFetchingLatestMods, setIsFetchingLatestMods] = useState(true) const [latestMods, setLatestMods] = useState([]) + const muteLists = useMuteLists() + useDidMount(() => { fetchMods({ source: window.location.host }) .then((res) => { - const mods = res - .sort((a, b) => b.published_at - a.published_at) - .slice(0, 4) + const mods = res.sort((a, b) => b.published_at - a.published_at) setLatestMods(mods) }) .finally(() => { @@ -271,6 +271,21 @@ const DisplayLatestMods = () => { }) }) + const filteredMods = useMemo(() => { + const mutedAuthors = [...muteLists.admin.authors, ...muteLists.user.authors] + const mutedEvents = [ + ...muteLists.admin.replaceableEvents, + ...muteLists.user.replaceableEvents + ] + + const filtered = latestMods.filter( + (mod) => + !mutedAuthors.includes(mod.author) && !mutedEvents.includes(mod.aTag) + ) + + return filtered.slice(0, 4) + }, [muteLists, latestMods]) + return (
@@ -280,7 +295,7 @@ const DisplayLatestMods = () => { {isFetchingLatestMods ? ( ) : ( - latestMods.map((mod) => { + filteredMods.map((mod) => { return }) )} diff --git a/src/pages/mod/index.tsx b/src/pages/mod/index.tsx index ac1636f..1c3cee6 100644 --- a/src/pages/mod/index.tsx +++ b/src/pages/mod/index.tsx @@ -1344,6 +1344,14 @@ const Download = ({

{showAuthDetails && (
+
+
+

Download URL

+
+
+

{url}

+
+

SHA-256 hash