Fix linting errors
This commit is contained in:
parent
44efa3e490
commit
b71bb09723
4 changed files with 18 additions and 12 deletions
|
|
@ -81,8 +81,8 @@ const CharacterConflictModal = (props: Props) => {
|
||||||
</p>
|
</p>
|
||||||
<div className="diagram">
|
<div className="diagram">
|
||||||
<ul>
|
<ul>
|
||||||
{props.conflictingCharacters?.map((character) => (
|
{props.conflictingCharacters?.map((character, i) => (
|
||||||
<li className="character">
|
<li className="character" key={`conflict-${i}`}>
|
||||||
<img
|
<img
|
||||||
alt={character.object.name.en}
|
alt={character.object.name.en}
|
||||||
src={imageUrl(character.object, character.uncap_level)}
|
src={imageUrl(character.object, character.uncap_level)}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import { appState } from "~utils/appState"
|
||||||
|
|
||||||
import "./index.scss"
|
import "./index.scss"
|
||||||
import CharacterConflictModal from "~components/CharacterConflictModal"
|
import CharacterConflictModal from "~components/CharacterConflictModal"
|
||||||
import { resolve } from "path"
|
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -49,7 +48,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
// Create a temporary state to store previous character uncap values
|
// Create a temporary state to store previous character uncap values
|
||||||
const [previousUncapValues, setPreviousUncapValues] = useState<{
|
const [previousUncapValues, setPreviousUncapValues] = useState<{
|
||||||
[key: number]: number
|
[key: number]: number | undefined
|
||||||
}>({})
|
}>({})
|
||||||
|
|
||||||
// Set the editable flag only on first load
|
// 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
|
// Initialize an array of current uncap values for each characters
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let initialPreviousUncapValues: { [key: number]: number } = {}
|
let initialPreviousUncapValues: { [key: number]: number } = {}
|
||||||
Object.values(appState.grid.characters).map(
|
Object.values(appState.grid.characters).map((o) => {
|
||||||
(o) => (initialPreviousUncapValues[o.position] = o.uncap_level)
|
o ? (initialPreviousUncapValues[o.position] = o.uncap_level) : -1
|
||||||
)
|
})
|
||||||
setPreviousUncapValues(initialPreviousUncapValues)
|
setPreviousUncapValues(initialPreviousUncapValues)
|
||||||
}, [appState.grid.characters])
|
}, [appState.grid.characters])
|
||||||
|
|
||||||
|
|
@ -230,8 +229,15 @@ const CharacterGrid = (props: Props) => {
|
||||||
[props, saveUncap]
|
[props, saveUncap]
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
const updateUncapLevel = (
|
||||||
appState.grid.characters[position].uncap_level = uncapLevel
|
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) {
|
function storePreviousUncapValue(position: number) {
|
||||||
|
|
@ -239,7 +245,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (grid.characters[position]) {
|
if (grid.characters[position]) {
|
||||||
newPreviousValues[position] = grid.characters[position].uncap_level
|
newPreviousValues[position] = grid.characters[position]?.uncap_level
|
||||||
setPreviousUncapValues(newPreviousValues)
|
setPreviousUncapValues(newPreviousValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
types/GridArray.d.ts
vendored
2
types/GridArray.d.ts
vendored
|
|
@ -1 +1 @@
|
||||||
type GridArray<T> = { [key: number]: T }
|
type GridArray<T> = { [key: number]: T | undefined }
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ interface AppState {
|
||||||
friendSummon: GridSummon | undefined
|
friendSummon: GridSummon | undefined
|
||||||
allSummons: GridArray<GridSummon>
|
allSummons: GridArray<GridSummon>
|
||||||
}
|
}
|
||||||
characters: GridArray<GridCharacter | undefined>
|
characters: GridArray<GridCharacter>
|
||||||
}
|
}
|
||||||
search: {
|
search: {
|
||||||
recents: {
|
recents: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue