From 2a202bb60d06a5a6aa1898075666aae216f4b149 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 29 Jan 2023 02:11:07 -0800 Subject: [PATCH 1/3] Don't allow selecting skill without selecting job --- components/JobSection/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/JobSection/index.tsx b/components/JobSection/index.tsx index 96bc374b..e0c68a4d 100644 --- a/components/JobSection/index.tsx +++ b/components/JobSection/index.tsx @@ -115,7 +115,7 @@ const JobSection = (props: Props) => { const canEditSkill = (skill?: JobSkill) => { // If there is a job and a skill present in the slot - if (job) { + if (job && job.id !== '-1') { // If the skill's job is one of the job's main skill if (skill && skill.job.id === job.id && skill.main) return false From 25362d81df1f58294b2e037fc6c2b64371ed6e25 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 29 Jan 2023 16:14:53 -0800 Subject: [PATCH 2/3] Remove unused state --- components/CharacterGrid/index.tsx | 1 - components/SummonGrid/index.tsx | 1 - components/WeaponGrid/index.tsx | 1 - 3 files changed, 3 deletions(-) diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index 944f4e85..b97218da 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -47,7 +47,6 @@ const CharacterGrid = (props: Props) => { // Set up state for view management const { party, grid } = useSnapshot(appState) - const [slug, setSlug] = useState() const [modalOpen, setModalOpen] = useState(false) // Set up state for conflict management diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 511befcc..1263658b 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -45,7 +45,6 @@ const SummonGrid = (props: Props) => { // Set up state for view management const { party, grid } = useSnapshot(appState) - const [slug, setSlug] = useState() // Create a temporary state to store previous weapon uncap values and transcendence stages const [previousUncapValues, setPreviousUncapValues] = useState<{ diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index ee73a003..4dbdc346 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -48,7 +48,6 @@ const WeaponGrid = (props: Props) => { // Set up state for view management const { party, grid } = useSnapshot(appState) - const [slug, setSlug] = useState() const [modalOpen, setModalOpen] = useState(false) // Set up state for conflict management From b3ec6a5d0835e5b85581d7521954b25e5a4885d4 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 29 Jan 2023 16:20:14 -0800 Subject: [PATCH 3/3] 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 }, [])