EditProfile: refactor initialState

stable/1.0.x
Alex Gleason 2020-05-28 15:09:59 -05:00
rodzic 1d44de0873
commit c4c99a1c1b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -115,18 +115,20 @@ class EditProfile extends ImmutablePureComponent {
event.preventDefault(); event.preventDefault();
} }
componentWillMount() { setInitialState = () => {
const { account } = this.props; const initialState = this.props.account.withMutations(map => {
const sourceData = account.get('source'); map.merge(map.get('source'));
const accountData = account.merge(sourceData).delete('source'); map.delete('source');
const fields = normalizeFields(accountData.get('fields')); map.set('fields', normalizeFields(map.get('fields')));
const initialState = unescapeParams( unescapeParams(map, ['display_name', 'note']);
accountData.set('fields', fields), });
['display_name', 'note']
);
this.setState(initialState.toObject()); this.setState(initialState.toObject());
} }
componentWillMount() {
this.setInitialState();
}
handleCheckboxChange = e => { handleCheckboxChange = e => {
this.setState({ [e.target.name]: e.target.checked }); this.setState({ [e.target.name]: e.target.checked });
} }