Also prevent updating uncap stars on Character/Summon grids

This commit is contained in:
Justin Edmund 2023-01-02 02:08:01 -08:00
parent d3c2c6846b
commit 3e32871107
2 changed files with 20 additions and 6 deletions

View file

@ -15,6 +15,7 @@ import type { JobSkillObject, SearchableObject } from '~types'
import api from '~utils/api' import api from '~utils/api'
import { appState } from '~utils/appState' import { appState } from '~utils/appState'
import { accountState } from '~utils/accountState'
import './index.scss' import './index.scss'
@ -282,12 +283,18 @@ const CharacterGrid = (props: Props) => {
id: string, id: string,
position: number, position: number,
uncapLevel: number uncapLevel: number
) {
if (
party.user &&
accountState.account.user &&
party.user.id === accountState.account.user.id
) { ) {
memoizeAction(id, position, uncapLevel) memoizeAction(id, position, uncapLevel)
// Optimistically update UI // Optimistically update UI
updateUncapLevel(position, uncapLevel) updateUncapLevel(position, uncapLevel)
} }
}
const memoizeAction = useCallback( const memoizeAction = useCallback(
(id: string, position: number, uncapLevel: number) => { (id: string, position: number, uncapLevel: number) => {

View file

@ -12,6 +12,7 @@ import ExtraSummons from '~components/ExtraSummons'
import api from '~utils/api' import api from '~utils/api'
import { appState } from '~utils/appState' import { appState } from '~utils/appState'
import { accountState } from '~utils/accountState'
import type { SearchableObject } from '~types' import type { SearchableObject } from '~types'
import './index.scss' import './index.scss'
@ -155,12 +156,18 @@ const SummonGrid = (props: Props) => {
id: string, id: string,
position: number, position: number,
uncapLevel: number uncapLevel: number
) {
if (
party.user &&
accountState.account.user &&
party.user.id === accountState.account.user.id
) { ) {
memoizeAction(id, position, uncapLevel) memoizeAction(id, position, uncapLevel)
// Optimistically update UI // Optimistically update UI
updateUncapLevel(position, uncapLevel) updateUncapLevel(position, uncapLevel)
} }
}
const memoizeAction = useCallback( const memoizeAction = useCallback(
(id: string, position: number, uncapLevel: number) => { (id: string, position: number, uncapLevel: number) => {