From b42bef99fe2c4ac5194c8710f6e3ef5a74f05c7f Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 4 Feb 2022 02:11:05 -0800 Subject: [PATCH] Fix bug with uncap levels on Summons and Characters --- components/CharacterGrid/index.tsx | 8 ++++---- components/SummonGrid/index.tsx | 6 +++--- components/WeaponGrid/index.tsx | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index ac5c08ce..5a9b4064 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -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) => { diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 3b337fef..c19ba415 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -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) => { diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index fed35048..a15a6863 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -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 {