Don't POST if the user is adding the same weapon to a position
This commit is contained in:
parent
fa6b312f06
commit
05df606ea4
1 changed files with 28 additions and 9 deletions
|
|
@ -152,15 +152,34 @@ const WeaponGrid = (props: Props) => {
|
||||||
if (weapon.uncap.ulb) uncapLevel = 5
|
if (weapon.uncap.ulb) uncapLevel = 5
|
||||||
else if (weapon.uncap.flb) uncapLevel = 4
|
else if (weapon.uncap.flb) uncapLevel = 4
|
||||||
|
|
||||||
return await api.endpoints.weapons.create({
|
let post = false
|
||||||
weapon: {
|
if (
|
||||||
party_id: partyId,
|
position === -1 &&
|
||||||
weapon_id: weapon.id,
|
(!appState.grid.weapons.mainWeapon ||
|
||||||
position: position,
|
(appState.grid.weapons.mainWeapon &&
|
||||||
mainhand: position == -1,
|
appState.grid.weapons.mainWeapon.object.id !== weapon.id))
|
||||||
uncap_level: uncapLevel,
|
) {
|
||||||
},
|
post = true
|
||||||
})
|
} else if (
|
||||||
|
position !== -1 &&
|
||||||
|
(!appState.grid.weapons.allWeapons[position] ||
|
||||||
|
(appState.grid.weapons.allWeapons[position] &&
|
||||||
|
appState.grid.weapons.allWeapons[position]?.object.id !== weapon.id))
|
||||||
|
) {
|
||||||
|
post = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post) {
|
||||||
|
return await api.endpoints.weapons.create({
|
||||||
|
weapon: {
|
||||||
|
party_id: partyId,
|
||||||
|
weapon_id: weapon.id,
|
||||||
|
position: position,
|
||||||
|
mainhand: position == -1,
|
||||||
|
uncap_level: uncapLevel,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function storeGridWeapon(gridWeapon: GridWeapon) {
|
function storeGridWeapon(gridWeapon: GridWeapon) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue