Fix values staying in Edit team even if not saved
The values a user entered in the Edit team modal would persist even if the user hit cancel to close the modal. They wouldn't save to the server, but very confusing nonetheless. Now fixed.
This commit is contained in:
parent
23d37bba93
commit
f7f17cba1c
1 changed files with 18 additions and 13 deletions
|
|
@ -74,25 +74,15 @@ const EditPartyModal = ({ updateCallback, ...props }: Props) => {
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!party) return
|
persistFromState()
|
||||||
|
|
||||||
setName(party.name ? party.name : '')
|
|
||||||
setDescription(party.description ? party.description : '')
|
|
||||||
setRaid(party.raid)
|
|
||||||
setAutoGuard(party.autoGuard)
|
|
||||||
setAutoSummon(party.autoSummon)
|
|
||||||
setFullAuto(party.fullAuto)
|
|
||||||
setChargeAttack(party.chargeAttack)
|
|
||||||
setClearTime(party.clearTime)
|
|
||||||
if (party.turnCount) setTurnCount(party.turnCount)
|
|
||||||
if (party.buttonCount) setButtonCount(party.buttonCount)
|
|
||||||
if (party.chainCount) setChainCount(party.chainCount)
|
|
||||||
}, [party])
|
}, [party])
|
||||||
|
|
||||||
// Methods: Event handlers (Dialog)
|
// Methods: Event handlers (Dialog)
|
||||||
function openChange() {
|
function openChange() {
|
||||||
if (open) {
|
if (open) {
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
|
setCurrentSegment(0)
|
||||||
|
persistFromState()
|
||||||
if (props.onOpenChange) props.onOpenChange(false)
|
if (props.onOpenChange) props.onOpenChange(false)
|
||||||
} else {
|
} else {
|
||||||
setOpen(true)
|
setOpen(true)
|
||||||
|
|
@ -183,6 +173,21 @@ const EditPartyModal = ({ updateCallback, ...props }: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Data methods
|
// Methods: Data methods
|
||||||
|
function persistFromState() {
|
||||||
|
if (!party) return
|
||||||
|
setName(party.name ? party.name : '')
|
||||||
|
setDescription(party.description ? party.description : '')
|
||||||
|
setRaid(party.raid)
|
||||||
|
setAutoGuard(party.autoGuard)
|
||||||
|
setAutoSummon(party.autoSummon)
|
||||||
|
setFullAuto(party.fullAuto)
|
||||||
|
setChargeAttack(party.chargeAttack)
|
||||||
|
setClearTime(party.clearTime)
|
||||||
|
if (party.turnCount) setTurnCount(party.turnCount)
|
||||||
|
if (party.buttonCount) setButtonCount(party.buttonCount)
|
||||||
|
if (party.chainCount) setChainCount(party.chainCount)
|
||||||
|
}
|
||||||
|
|
||||||
function updateDetails(event: React.MouseEvent) {
|
function updateDetails(event: React.MouseEvent) {
|
||||||
const descriptionValue = descriptionInput.current?.value
|
const descriptionValue = descriptionInput.current?.value
|
||||||
const details: DetailsObject = {
|
const details: DetailsObject = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue