EditProfile: Unescape account params in componentWillMount()

merge-requests/30/merge
Alex Gleason 4 years ago
parent 76b3849c93
commit 1d44de0873
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -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…
Cancel
Save