Fix bug with uncap levels on Summons and Characters

This commit is contained in:
Justin Edmund 2022-02-04 02:11:05 -08:00
parent 5bd6ac4bc7
commit b42bef99fe
3 changed files with 7 additions and 8 deletions

View file

@ -66,7 +66,7 @@ const CharacterGrid = (props: Props) => {
let initialPreviousUncapValues: {[key: number]: number} = {}
Object.values(characters).map(o => initialPreviousUncapValues[o.position] = o.uncap_level)
setPreviousUncapValues(initialPreviousUncapValues)
}, [props])
}, [characters])
// Update search grid whenever characters are updated
useEffect(() => {
@ -194,7 +194,7 @@ const CharacterGrid = (props: Props) => {
try {
if (uncapLevel != previousUncapValues[position])
await api.updateUncap('weapon', id, uncapLevel)
await api.updateUncap('character', id, uncapLevel)
.then(response => { storeGridCharacter(response.data.grid_character) })
} catch (error) {
console.error(error)
@ -221,13 +221,13 @@ const CharacterGrid = (props: Props) => {
const memoizeAction = useCallback(
(id: string, position: number, uncapLevel: number) => {
debouncedAction(id, position, uncapLevel)
}, [props]
}, [characters]
)
const debouncedAction = useMemo(() =>
debounce((id, position, number) => {
saveUncap(id, position, number)
}, 500), [props, saveUncap]
}, 500), [characters, saveUncap]
)
const updateUncapLevel = (position: number, uncapLevel: number) => {

View file

@ -71,7 +71,7 @@ const SummonGrid = (props: Props) => {
if (friendSummon) initialPreviousUncapValues[6] = friendSummon.uncap_level
Object.values(summons).map(o => initialPreviousUncapValues[o.position] = o.uncap_level)
setPreviousUncapValues(initialPreviousUncapValues)
}, [props])
}, [summons, mainSummon, friendSummon])
// Update search grid whenever any summon is updated
useEffect(() => {
@ -230,13 +230,13 @@ const SummonGrid = (props: Props) => {
const memoizeAction = useCallback(
(id: string, position: number, uncapLevel: number) => {
debouncedAction(id, position, uncapLevel)
}, [props]
}, [summons, mainSummon, friendSummon]
)
const debouncedAction = useMemo(() =>
debounce((id, position, number) => {
saveUncap(id, position, number)
}, 500), [props, saveUncap]
}, 500), [summons, mainSummon, friendSummon, saveUncap]
)
const updateUncapLevel = (position: number, uncapLevel: number) => {

View file

@ -15,7 +15,6 @@ import ExtraWeapons from '~components/ExtraWeapons'
import api from '~utils/api'
import './index.scss'
import Party from '~components/Party'
// Props
interface Props {