Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(home): do not mutate autopilot allocation
Browse files Browse the repository at this point in the history
Modify autopilotAllocation in `onSubmit` handler rather than `preSubmit`
as preSubmit mutates the data in the form state which can result in
the field being populated with an invalid value in the case that lnd
fails to start.

See https://github.com/joepuzzo/informed/pull/118
  • Loading branch information
mrfelton committed Dec 18, 2018
1 parent 4055e7a commit df51d40
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/components/Home/WalletSettingsFormLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@ class WalletSettingsFormLocal extends React.Component {
}
}

preSubmit = values => {
if (values.autopilotAllocation) {
values.autopilotAllocation = values.autopilotAllocation / 100
}
return values
}

onSubmit = async values => {
const { startLnd } = this.props

// Lnd expects the autopilot allocation to be a decimal.
values.autopilotAllocation = values.autopilotAllocation / 100

return startLnd(values)
}

Expand All @@ -54,7 +51,6 @@ class WalletSettingsFormLocal extends React.Component {
return (
<Form
getApi={this.setFormApi}
preSubmit={this.preSubmit}
onSubmit={this.onSubmit}
{...rest}
initialValues={wallet}
Expand Down

0 comments on commit df51d40

Please sign in to comment.