From b3ec6a5d0835e5b85581d7521954b25e5a4885d4 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 29 Jan 2023 16:20:14 -0800 Subject: [PATCH] Fix job dropdown not showing jobs This was happening due to a combination of the useEffect not being updated properly in the New route and the state being completely reset when cleaned in the new route, including values that should persist. --- components/JobSection/index.tsx | 1 - pages/new/index.tsx | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/JobSection/index.tsx b/components/JobSection/index.tsx index e0c68a4d..f88a4016 100644 --- a/components/JobSection/index.tsx +++ b/components/JobSection/index.tsx @@ -10,7 +10,6 @@ import SearchModal from '~components/SearchModal' import api from '~utils/api' import { appState } from '~utils/appState' -import { ACCESSORY_JOB_IDS } from '~utils/jobsWithAccessories' import type { JobSkillObject, SearchableObject } from '~types' import './index.scss' diff --git a/pages/new/index.tsx b/pages/new/index.tsx index a25d3f8f..e03a3cfa 100644 --- a/pages/new/index.tsx +++ b/pages/new/index.tsx @@ -65,14 +65,19 @@ const NewRoute: React.FC = ({ appState.weaponKeys = context.weaponKeys } appState.version = version - }, []) + }, [context, version]) useEffect(() => { // Clean state const resetState = clonedeep(initialAppState) - Object.keys(resetState).forEach((key) => { - appState[key] = resetState[key] - }) + appState.party = resetState.party + appState.grid = resetState.grid + + // Old method kept in case we need it later + // Object.keys(resetState).forEach((key) => { + // appState[key] = resetState[key] + // }) + // Set party to be editable appState.party.editable = true }, [])