From 5d275091488b280ef276b2d9d44153b93356e402 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 3 Feb 2022 19:50:06 -0800 Subject: [PATCH] Update the element when the weapon swaps This is still broken, we have to rewrite some API calls to fix it. --- components/WeaponGrid/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index c1e05f8f..d18f877d 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -71,6 +71,7 @@ const WeaponGrid = (props: Props) => { setPartyId(props.partyId || '') setWeapons(props.weapons || {}) setMainWeapon(props.mainhand) + if (props.mainhand) setElement(props.mainhand.weapon.element) }, [props]) // Initialize an array of current uncap values for each weapon @@ -81,10 +82,6 @@ const WeaponGrid = (props: Props) => { setPreviousUncapValues(initialPreviousUncapValues) }, [props]) - useEffect(() => { - if (mainWeapon) setElement(mainWeapon.weapon.element) - }, [mainWeapon]) - // Update search grid whenever weapons or the mainhand are updated useEffect(() => { let newSearchGrid = Object.values(weapons).map((o) => o.weapon) @@ -103,6 +100,7 @@ const WeaponGrid = (props: Props) => { function receiveWeaponFromSearch(object: Character | Weapon | Summon, position: number) { const weapon = object as Weapon + setElement(weapon.element) if (!partyId) { props.createParty()