From df51d40b89a850dcd27b13000b06acc6ced4eb41 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Tue, 18 Dec 2018 23:10:50 +0100 Subject: [PATCH] fix(home): do not mutate autopilot allocation 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 --- app/components/Home/WalletSettingsFormLocal.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/components/Home/WalletSettingsFormLocal.js b/app/components/Home/WalletSettingsFormLocal.js index a17bb153396..118db7f716d 100644 --- a/app/components/Home/WalletSettingsFormLocal.js +++ b/app/components/Home/WalletSettingsFormLocal.js @@ -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) } @@ -54,7 +51,6 @@ class WalletSettingsFormLocal extends React.Component { return (