fix #624, remove unnecessary settings state

This commit is contained in:
Jeremy Kauffman 2017-09-29 16:05:26 -04:00
parent f4b2c599c3
commit d39664a0fd

View file

@ -13,8 +13,6 @@ class SettingsPage extends React.PureComponent {
super(props); super(props);
this.state = { this.state = {
instantPurchaseEnabled: props.instantPurchaseEnabled,
instantPurchaseMax: props.instantPurchaseMax,
clearingCache: false, clearingCache: false,
}; };
} }
@ -49,7 +47,14 @@ class SettingsPage extends React.PureComponent {
} }
onKeyFeeChange(newValue) { onKeyFeeChange(newValue) {
this.setDaemonSetting("max_key_fee", newValue); let setting = newValue;
//this is stupid and should be fixed... somewhere
if (setting && (setting.amount === undefined || setting.amount === null)) {
setting.amount = 0;
}
this.setDaemonSetting("max_key_fee", setting);
} }
onKeyFeeDisableChange(isDisabled) { onKeyFeeDisableChange(isDisabled) {
@ -61,20 +66,12 @@ class SettingsPage extends React.PureComponent {
this.props.setClientSetting(settings.THEME, value); this.props.setClientSetting(settings.THEME, value);
} }
oninstantPurchaseEnabledChange(enabled) { onInstantPurchaseEnabledChange(enabled) {
this.props.setClientSetting(settings.INSTANT_PURCHASE_ENABLED, enabled); this.props.setClientSetting(settings.INSTANT_PURCHASE_ENABLED, enabled);
this.setState({
instantPurchaseEnabled: enabled,
});
} }
onInstantPurchaseMaxChange(newValue) { onInstantPurchaseMaxChange(newValue) {
this.props.setClientSetting(settings.INSTANT_PURCHASE_MAX, newValue); this.props.setClientSetting(settings.INSTANT_PURCHASE_MAX, newValue);
this.setState({
instantPurchaseMax: newValue,
});
} }
// onMaxUploadPrefChange(isLimited) { // onMaxUploadPrefChange(isLimited) {
@ -245,31 +242,31 @@ class SettingsPage extends React.PureComponent {
<FormRow <FormRow
type="radio" type="radio"
name="instant_purchase_max" name="instant_purchase_max"
checked={!this.state.instantPurchaseEnabled} checked={!instantPurchaseEnabled}
label={__("Ask for confirmation of all purchases")} label={__("Ask for confirmation of all purchases")}
onClick={e => { onClick={e => {
this.oninstantPurchaseEnabledChange(false); this.onInstantPurchaseEnabledChange(false);
}} }}
/> />
<div className="form-row"> <div className="form-row">
<FormField <FormField
type="radio" type="radio"
name="instant_purchase_max" name="instant_purchase_max"
checked={this.state.instantPurchaseEnabled} checked={instantPurchaseEnabled}
label={ label={
"Single-click purchasing of content less than" + "Single-click purchasing of content less than" +
(this.state.instantPurchaseEnabled ? "" : "...") (instantPurchaseEnabled ? "" : "...")
} }
onClick={e => { onClick={e => {
this.oninstantPurchaseEnabledChange(true); this.onInstantPurchaseEnabledChange(true);
}} }}
/> />
{this.state.instantPurchaseEnabled && {instantPurchaseEnabled &&
<FormFieldPrice <FormFieldPrice
min="0.1" min="0.1"
step="0.1" step="0.1"
onChange={val => this.onInstantPurchaseMaxChange(val)} onChange={val => this.onInstantPurchaseMaxChange(val)}
defaultValue={this.state.instantPurchaseMax} defaultValue={instantPurchaseMax}
/>} />}
</div> </div>
<div className="form-field__helper"> <div className="form-field__helper">