Bio fixes
This commit is contained in:
parent
695a78503d
commit
b30dc39f1a
2 changed files with 10 additions and 13 deletions
|
@ -4,6 +4,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { showAlert } from 'soapbox/actions/alerts';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
|
@ -19,7 +20,7 @@ import {
|
||||||
List as ImmutableList,
|
List as ImmutableList,
|
||||||
} from 'immutable';
|
} from 'immutable';
|
||||||
import { patchMe } from 'soapbox/actions/me';
|
import { patchMe } from 'soapbox/actions/me';
|
||||||
import { unescape, escape } from 'lodash';
|
import { unescape } from 'lodash';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
heading: { id: 'column.edit_profile', defaultMessage: 'Edit profile' },
|
heading: { id: 'column.edit_profile', defaultMessage: 'Edit profile' },
|
||||||
|
@ -71,7 +72,7 @@ class EditProfile extends ImmutablePureComponent {
|
||||||
map.merge(map.get('source'));
|
map.merge(map.get('source'));
|
||||||
map.delete('source');
|
map.delete('source');
|
||||||
map.set('fields', normalizeFields(map.get('fields'), props.maxFields));
|
map.set('fields', normalizeFields(map.get('fields'), props.maxFields));
|
||||||
unescapeParams(map, ['display_name']);
|
unescapeParams(map, ['display_name', 'bio']);
|
||||||
});
|
});
|
||||||
this.state = initialState.toObject();
|
this.state = initialState.toObject();
|
||||||
}
|
}
|
||||||
|
@ -112,9 +113,8 @@ class EditProfile extends ImmutablePureComponent {
|
||||||
const data = this.getParams();
|
const data = this.getParams();
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
for (let key in data) {
|
for (let key in data) {
|
||||||
const shouldAppend = Boolean(data[key]
|
// Compact the submission. This should probably be done better.
|
||||||
|| key.startsWith('fields_attributes')
|
const shouldAppend = Boolean(data[key] || key.startsWith('fields_attributes'));
|
||||||
|| key.startsWith('note'));
|
|
||||||
if (shouldAppend) formData.append(key, data[key] || '');
|
if (shouldAppend) formData.append(key, data[key] || '');
|
||||||
}
|
}
|
||||||
return formData;
|
return formData;
|
||||||
|
@ -124,6 +124,7 @@ class EditProfile extends ImmutablePureComponent {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
dispatch(patchMe(this.getFormdata())).then(() => {
|
dispatch(patchMe(this.getFormdata())).then(() => {
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
|
dispatch(showAlert('', 'Profile saved!'));
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
});
|
});
|
||||||
|
@ -139,11 +140,6 @@ class EditProfile extends ImmutablePureComponent {
|
||||||
this.setState({ [e.target.name]: e.target.value });
|
this.setState({ [e.target.name]: e.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTextAreaChange = e => {
|
|
||||||
const value = escape(e.target.value);
|
|
||||||
this.setState({ [e.target.name]: value });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFieldChange = (i, key) => {
|
handleFieldChange = (i, key) => {
|
||||||
return (e) => {
|
return (e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -185,9 +181,10 @@ class EditProfile extends ImmutablePureComponent {
|
||||||
label={<FormattedMessage id='edit_profile.fields.bio_label' defaultMessage='Bio' />}
|
label={<FormattedMessage id='edit_profile.fields.bio_label' defaultMessage='Bio' />}
|
||||||
name='note'
|
name='note'
|
||||||
autoComplete='off'
|
autoComplete='off'
|
||||||
value={this.state.note.replace(/<br\s*\/?>/gi, '\n')}
|
value={this.state.note}
|
||||||
wrap='hard'
|
wrap='hard'
|
||||||
onChange={this.handleTextAreaChange}
|
onChange={this.handleTextChange}
|
||||||
|
rows={3}
|
||||||
/>
|
/>
|
||||||
<div className='fields-row'>
|
<div className='fields-row'>
|
||||||
<div className='fields-row__column fields-row__column-6'>
|
<div className='fields-row__column fields-row__column-6'>
|
||||||
|
|
|
@ -346,7 +346,7 @@ code {
|
||||||
input[type=number][disabled],
|
input[type=number][disabled],
|
||||||
input[type=email][disabled],
|
input[type=email][disabled],
|
||||||
input[type=password][disabled],
|
input[type=password][disabled],
|
||||||
textarea {
|
textarea[disabled] {
|
||||||
color: var(--primary-text-color--faint);
|
color: var(--primary-text-color--faint);
|
||||||
border-color: var(--primary-text-color--faint);
|
border-color: var(--primary-text-color--faint);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue