Unify and finalize optimistic UI updates
This commit is contained in:
parent
971f04e88f
commit
814a25d005
2 changed files with 28 additions and 6 deletions
|
|
@ -274,6 +274,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
// Note: Saves, but debouncing is not working properly
|
// Note: Saves, but debouncing is not working properly
|
||||||
async function saveUncap(id: string, position: number, uncapLevel: number) {
|
async function saveUncap(id: string, position: number, uncapLevel: number) {
|
||||||
storePreviousUncapValue(position)
|
storePreviousUncapValue(position)
|
||||||
|
storePreviousTranscendenceStage(position)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (uncapLevel != previousUncapValues[position])
|
if (uncapLevel != previousUncapValues[position])
|
||||||
|
|
@ -285,11 +286,17 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
// Revert optimistic UI
|
// Revert optimistic UI
|
||||||
updateUncapLevel(position, previousUncapValues[position])
|
updateUncapLevel(position, previousUncapValues[position])
|
||||||
|
updateTranscendenceStage(position, previousTranscendenceStages[position])
|
||||||
|
|
||||||
// Remove optimistic key
|
// Remove optimistic key
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousTranscendenceStages = { ...previousTranscendenceStages }
|
||||||
delete newPreviousValues[position]
|
let newPreviousUncapValues = { ...previousUncapValues }
|
||||||
setPreviousUncapValues(newPreviousValues)
|
|
||||||
|
delete newPreviousTranscendenceStages[position]
|
||||||
|
delete newPreviousUncapValues[position]
|
||||||
|
|
||||||
|
setPreviousTranscendenceStages(newPreviousTranscendenceStages)
|
||||||
|
setPreviousUncapValues(newPreviousUncapValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ const SummonGrid = (props: Props) => {
|
||||||
// Note: Saves, but debouncing is not working properly
|
// Note: Saves, but debouncing is not working properly
|
||||||
async function saveUncap(id: string, position: number, uncapLevel: number) {
|
async function saveUncap(id: string, position: number, uncapLevel: number) {
|
||||||
storePreviousUncapValue(position)
|
storePreviousUncapValue(position)
|
||||||
|
storePreviousTranscendenceStage(position)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (uncapLevel != previousUncapValues[position])
|
if (uncapLevel != previousUncapValues[position])
|
||||||
|
|
@ -170,11 +171,17 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
// Revert optimistic UI
|
// Revert optimistic UI
|
||||||
updateUncapLevel(position, previousUncapValues[position])
|
updateUncapLevel(position, previousUncapValues[position])
|
||||||
|
updateTranscendenceStage(position, previousTranscendenceStages[position])
|
||||||
|
|
||||||
// Remove optimistic key
|
// Remove optimistic key
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousTranscendenceStages = { ...previousTranscendenceStages }
|
||||||
delete newPreviousValues[position]
|
let newPreviousUncapValues = { ...previousUncapValues }
|
||||||
setPreviousUncapValues(newPreviousValues)
|
|
||||||
|
delete newPreviousTranscendenceStages[position]
|
||||||
|
delete newPreviousUncapValues[position]
|
||||||
|
|
||||||
|
setPreviousTranscendenceStages(newPreviousTranscendenceStages)
|
||||||
|
setPreviousUncapValues(newPreviousUncapValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,6 +199,10 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
// Optimistically update UI
|
// Optimistically update UI
|
||||||
updateUncapLevel(position, uncapLevel)
|
updateUncapLevel(position, uncapLevel)
|
||||||
|
|
||||||
|
if (uncapLevel < 6) {
|
||||||
|
updateTranscendenceStage(position, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,6 +309,10 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
// Optimistically update UI
|
// Optimistically update UI
|
||||||
updateTranscendenceStage(position, stage)
|
updateTranscendenceStage(position, stage)
|
||||||
|
|
||||||
|
if (stage > 0) {
|
||||||
|
updateUncapLevel(position, 6)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue