Remove unused methods and props from WeaponGrid tree
This commit is contained in:
parent
9b505f5e20
commit
bc93565dc5
3 changed files with 3 additions and 33 deletions
|
|
@ -9,7 +9,6 @@ interface Props {
|
|||
editable: boolean
|
||||
found?: boolean
|
||||
offset: number
|
||||
onClick: (position: number) => void
|
||||
updateObject: (object: Character | Weapon | Summon, position: number) => void
|
||||
updateUncap: (id: string, position: number, uncap: number) => void
|
||||
}
|
||||
|
|
@ -30,7 +29,6 @@ const ExtraWeapons = (props: Props) => {
|
|||
position={props.offset + i}
|
||||
unitType={1}
|
||||
gridWeapon={props.grid[props.offset + i]}
|
||||
onClick={() => { props.onClick(props.offset + i)}}
|
||||
updateObject={props.updateObject}
|
||||
updateUncap={props.updateUncap}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 're
|
|||
import { useCookies } from 'react-cookie'
|
||||
import { useSnapshot } from 'valtio'
|
||||
|
||||
import { useModal as useModal } from '~utils/useModal'
|
||||
import state from '~utils/state'
|
||||
|
||||
import { AxiosResponse } from 'axios'
|
||||
import debounce from 'lodash.debounce'
|
||||
|
||||
|
|
@ -13,6 +10,8 @@ import WeaponUnit from '~components/WeaponUnit'
|
|||
import ExtraWeapons from '~components/ExtraWeapons'
|
||||
|
||||
import api from '~utils/api'
|
||||
import state from '~utils/state'
|
||||
|
||||
import './index.scss'
|
||||
|
||||
// Props
|
||||
|
|
@ -41,16 +40,9 @@ const WeaponGrid = (props: Props) => {
|
|||
const [found, setFound] = useState(false)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
// Set up states for Search
|
||||
const { open, openModal, closeModal } = useModal()
|
||||
const [itemPositionForSearch, setItemPositionForSearch] = useState(0)
|
||||
|
||||
// Create a temporary state to store previous weapon uncap values
|
||||
const [previousUncapValues, setPreviousUncapValues] = useState<{[key: number]: number}>({})
|
||||
|
||||
// Create a state dictionary to store pure objects for Search
|
||||
const [searchGrid, setSearchGrid] = useState<GridArray<Weapon>>({})
|
||||
|
||||
// Fetch data from the server
|
||||
useEffect(() => {
|
||||
const shortcode = (props.slug) ? props.slug : slug
|
||||
|
|
@ -68,16 +60,6 @@ const WeaponGrid = (props: Props) => {
|
|||
setPreviousUncapValues(initialPreviousUncapValues)
|
||||
}, [state.grid.weapons.mainWeapon, state.grid.weapons.allWeapons])
|
||||
|
||||
// Update search grid whenever weapons or the mainhand are updated
|
||||
useEffect(() => {
|
||||
let newSearchGrid = Object.values(grid.weapons.allWeapons).map((o) => o.weapon)
|
||||
|
||||
if (state.grid.weapons.mainWeapon)
|
||||
newSearchGrid.unshift(state.grid.weapons.mainWeapon.weapon)
|
||||
|
||||
setSearchGrid(newSearchGrid)
|
||||
}, [state.grid.weapons.mainWeapon, state.grid.weapons.allWeapons])
|
||||
|
||||
// Methods: Fetching an object from the server
|
||||
async function fetchGrid(shortcode: string) {
|
||||
return api.endpoints.parties.getOneWithObject({ id: shortcode, object: 'weapons' })
|
||||
|
|
@ -132,12 +114,6 @@ const WeaponGrid = (props: Props) => {
|
|||
})
|
||||
}
|
||||
|
||||
// Methods: Adding an object from search
|
||||
function openSearchModal(position: number) {
|
||||
setItemPositionForSearch(position)
|
||||
openModal()
|
||||
}
|
||||
|
||||
function receiveWeaponFromSearch(object: Character | Weapon | Summon, position: number) {
|
||||
const weapon = object as Weapon
|
||||
if (position == 1)
|
||||
|
|
@ -251,7 +227,6 @@ const WeaponGrid = (props: Props) => {
|
|||
key="grid_mainhand"
|
||||
position={-1}
|
||||
unitType={0}
|
||||
onClick={() => { openSearchModal(-1) }}
|
||||
updateObject={receiveWeaponFromSearch}
|
||||
updateUncap={initiateUncapUpdate}
|
||||
/>
|
||||
|
|
@ -266,7 +241,6 @@ const WeaponGrid = (props: Props) => {
|
|||
editable={party.editable}
|
||||
position={i}
|
||||
unitType={1}
|
||||
onClick={() => { openSearchModal(i) }}
|
||||
updateObject={receiveWeaponFromSearch}
|
||||
updateUncap={initiateUncapUpdate}
|
||||
/>
|
||||
|
|
@ -280,7 +254,6 @@ const WeaponGrid = (props: Props) => {
|
|||
grid={state.grid.weapons.allWeapons}
|
||||
editable={party.editable}
|
||||
offset={numWeapons}
|
||||
onClick={openSearchModal}
|
||||
updateObject={receiveWeaponFromSearch}
|
||||
updateUncap={initiateUncapUpdate}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ interface Props {
|
|||
unitType: 0 | 1
|
||||
position: number
|
||||
editable: boolean
|
||||
onClick: () => void
|
||||
updateObject: (object: Character | Weapon | Summon, position: number) => void
|
||||
updateUncap: (id: string, position: number, uncap: number) => void
|
||||
}
|
||||
|
|
@ -62,7 +61,7 @@ const WeaponUnit = (props: Props) => {
|
|||
fromPosition={props.position}
|
||||
object="weapons"
|
||||
send={props.updateObject}>
|
||||
<div className="WeaponImage" onClick={ (props.editable) ? props.onClick : () => {} }>
|
||||
<div className="WeaponImage">
|
||||
<img alt={weapon?.name.en} className="grid_image" src={imageUrl} />
|
||||
{ (props.editable) ? <span className='icon'><PlusIcon /></span> : '' }
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue