EditProfile: Unescape account params in componentWillMount()
This commit is contained in:
parent
76b3849c93
commit
1d44de0873
1 changed files with 11 additions and 8 deletions
|
@ -40,6 +40,13 @@ const normalizeFields = fields => (
|
|||
)
|
||||
);
|
||||
|
||||
// HTML unescape for special chars, eg <br>
|
||||
const unescapeParams = (map, params) => (
|
||||
params.reduce((map, param) => (
|
||||
map.set(param, unescape(map.get(param)))
|
||||
), map)
|
||||
);
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class EditProfile extends ImmutablePureComponent {
|
||||
|
@ -113,17 +120,13 @@ class EditProfile extends ImmutablePureComponent {
|
|||
const sourceData = account.get('source');
|
||||
const accountData = account.merge(sourceData).delete('source');
|
||||
const fields = normalizeFields(accountData.get('fields'));
|
||||
const initialState = accountData.set('fields', fields);
|
||||
const initialState = unescapeParams(
|
||||
accountData.set('fields', fields),
|
||||
['display_name', 'note']
|
||||
);
|
||||
this.setState(initialState.toObject());
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const display_name = unescape(this.state.display_name);
|
||||
this.setState({ display_name: display_name });
|
||||
const note = unescape(this.state.note);
|
||||
this.setState({ note: note });
|
||||
}
|
||||
|
||||
handleCheckboxChange = e => {
|
||||
this.setState({ [e.target.name]: e.target.checked });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue