Update the element when the weapon swaps

This is still broken, we have to rewrite some API calls to fix it.
This commit is contained in:
Justin Edmund 2022-02-03 19:50:06 -08:00
parent a21a66c8ae
commit 5d27509148

View file

@ -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()