From b71bb0972336baafebff15b20ae3d88260cc8d3b Mon Sep 17 00:00:00 2001
From: Justin Edmund
Date: Sat, 19 Nov 2022 20:48:05 -0800
Subject: [PATCH] Fix linting errors
---
components/CharacterConflictModal/index.tsx | 4 ++--
components/CharacterGrid/index.tsx | 22 +++++++++++++--------
types/GridArray.d.ts | 2 +-
utils/appState.tsx | 2 +-
4 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/components/CharacterConflictModal/index.tsx b/components/CharacterConflictModal/index.tsx
index 5d393d28..04ade165 100644
--- a/components/CharacterConflictModal/index.tsx
+++ b/components/CharacterConflictModal/index.tsx
@@ -81,8 +81,8 @@ const CharacterConflictModal = (props: Props) => {
- {props.conflictingCharacters?.map((character) => (
- -
+ {props.conflictingCharacters?.map((character, i) => (
+
-
{
// Create a temporary state to store previous character uncap values
const [previousUncapValues, setPreviousUncapValues] = useState<{
- [key: number]: number
+ [key: number]: number | undefined
}>({})
// Set the editable flag only on first load
@@ -66,9 +65,9 @@ const CharacterGrid = (props: Props) => {
// Initialize an array of current uncap values for each characters
useEffect(() => {
let initialPreviousUncapValues: { [key: number]: number } = {}
- Object.values(appState.grid.characters).map(
- (o) => (initialPreviousUncapValues[o.position] = o.uncap_level)
- )
+ Object.values(appState.grid.characters).map((o) => {
+ o ? (initialPreviousUncapValues[o.position] = o.uncap_level) : -1
+ })
setPreviousUncapValues(initialPreviousUncapValues)
}, [appState.grid.characters])
@@ -230,8 +229,15 @@ const CharacterGrid = (props: Props) => {
[props, saveUncap]
)
- const updateUncapLevel = (position: number, uncapLevel: number) => {
- appState.grid.characters[position].uncap_level = uncapLevel
+ const updateUncapLevel = (
+ position: number,
+ uncapLevel: number | undefined
+ ) => {
+ const character = appState.grid.characters[position]
+ if (character && uncapLevel) {
+ character.uncap_level = uncapLevel
+ appState.grid.characters[position] = character
+ }
}
function storePreviousUncapValue(position: number) {
@@ -239,7 +245,7 @@ const CharacterGrid = (props: Props) => {
let newPreviousValues = { ...previousUncapValues }
if (grid.characters[position]) {
- newPreviousValues[position] = grid.characters[position].uncap_level
+ newPreviousValues[position] = grid.characters[position]?.uncap_level
setPreviousUncapValues(newPreviousValues)
}
}
diff --git a/types/GridArray.d.ts b/types/GridArray.d.ts
index ae10bdd7..92a0fb0f 100644
--- a/types/GridArray.d.ts
+++ b/types/GridArray.d.ts
@@ -1 +1 @@
-type GridArray = { [key: number]: T }
\ No newline at end of file
+type GridArray = { [key: number]: T | undefined }
diff --git a/utils/appState.tsx b/utils/appState.tsx
index dedf8e30..3a6725a6 100644
--- a/utils/appState.tsx
+++ b/utils/appState.tsx
@@ -43,7 +43,7 @@ interface AppState {
friendSummon: GridSummon | undefined
allSummons: GridArray
}
- characters: GridArray
+ characters: GridArray
}
search: {
recents: {