Showing "other currency" help tip in publish form now works. #447

Merged
hackrush01 merged 1 commit from price_form2 into master 2017-08-07 15:06:11 +02:00
4 changed files with 7 additions and 84 deletions

View file

@ -19,6 +19,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
### Fixed
* Tiles will no longer be blurry on hover (Windows only bug)
* Removed placeholder values from price selection form fields, which was causing confusion that these were real values (#426)
* Fixed showing "other currency" help tip in publish form, which was caused due to not "setting" state for price
*
### Deprecated
@ -27,6 +28,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
### Removed
* Removed the label "Max Purchase Price" from settings page. It was redundant.
* Unused old files from previous commit(9c3d633)
*
## [0.14.3] - 2017-08-03

View file

@ -1,5 +0,0 @@
import React from "react";
import { connect } from "react-redux";
import FormFieldPrice from "./view";
export default connect(null, null)(FormFieldPrice);

View file

@ -1,71 +0,0 @@
import React from "react";
import FormField from "component/formField";
class FormFieldPrice extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
price: {
feeAmount: "",
feeCurrency: "LBC",
},
};
}
handleFeeAmountChange(event) {
this.setState({
price: {
...this.state.price,
feeAmount: event.target.value,
},
});
this.props.onChange(event.target.name, this.state.price);
}
handleFeeCurrencyChange(event) {
this.setState({
price: {
...this.state.price,
feeCurrency: event.target.value,
},
});
this.props.onChange(event.target.name, this.state.price);
}
render() {
const {
defaultAmount,
defaultCurrency,
placeholder,
min,
step,
} = this.props;
return (
<span className={"form-field "}>
<FormField
type="number"
name="amount"
min={min}
placeholder={placeholder || null}
step={step}
onChange={event => this.handleFeeAmountChange(event)}
defaultValue={defaultAmount}
className="form-field__input--inline"
/>
<FormField
type="select"
name="currency"
onChange={event => this.handleFeeCurrencyChange(event)}
defaultValue={defaultCurrency}
className="form-field__input--inline"
>
<option value="LBC">{__("LBRY credits")}</option>
<option value="USD">{__("US Dollars")}</option>
</FormField>
</span>
);
}
}
export default FormFieldPrice;

View file

@ -309,8 +309,10 @@ class PublishForm extends React.PureComponent {
}
handleFeeChange(newValue) {
this.state.feeAmount = newValue.amount;
this.state.feeCurrency = newValue.currency;
this.setState({
feeAmount: newValue.amount,
feeCurrency: newValue.currency,
});
}
handleFeePrefChange(feeEnabled) {
@ -670,12 +672,7 @@ class PublishForm extends React.PureComponent {
onChange={val => this.handleFeeChange(val)}
/>
</span>
{/*
&& this.state.feeCurrency.toUpperCase() != "LBC"
for some reason, react does not trigger a re-render on currency change (despite trigger a state change), so
the above logic cannot be added to the below check
*/}
{this.state.isFee
{this.state.isFee && this.state.feeCurrency.toUpperCase() != "LBC"
? <div className="form-field__helper">
{__(
"All content fees are charged in LBC. For non-LBC payment methods, the number of credits charged will be adjusted based on the value of LBRY credits at the time of purchase."