Skip to content

Commit f8502c8

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Split out is_changing_upload from is_submitting (mastodon#9536)
There is no reason to disable the composer textarea when some media metadata is being modified, nor is there any reason to focus the textarea when some media metadata has been modified (prevents clicking one image's description field right after having modified another).
1 parent ad7230e commit f8502c8

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/javascript/mastodon/features/compose/components/compose_form.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ComposeForm extends ImmutablePureComponent {
4646
caretPosition: PropTypes.number,
4747
preselectDate: PropTypes.instanceOf(Date),
4848
is_submitting: PropTypes.bool,
49+
is_changing_upload: PropTypes.bool,
4950
is_uploading: PropTypes.bool,
5051
onChange: PropTypes.func.isRequired,
5152
onSubmit: PropTypes.func.isRequired,
@@ -81,10 +82,10 @@ class ComposeForm extends ImmutablePureComponent {
8182
}
8283

8384
// Submit disabled:
84-
const { is_submitting, is_uploading, anyMedia } = this.props;
85+
const { is_submitting, is_changing_upload, is_uploading, anyMedia } = this.props;
8586
const fulltext = [this.props.spoiler_text, countableText(this.props.text)].join('');
8687

87-
if (is_submitting || is_uploading || length(fulltext) > 500 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
88+
if (is_submitting || is_uploading || is_changing_upload || length(fulltext) > 500 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
8889
return;
8990
}
9091

@@ -160,7 +161,7 @@ class ComposeForm extends ImmutablePureComponent {
160161
const { intl, onPaste, showSearch, anyMedia } = this.props;
161162
const disabled = this.props.is_submitting;
162163
const text = [this.props.spoiler_text, countableText(this.props.text)].join('');
163-
const disabledButton = disabled || this.props.is_uploading || length(text) > 500 || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
164+
const disabledButton = disabled || this.props.is_uploading || this.props.is_changing_upload || length(text) > 500 || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
164165
let publishText = '';
165166

166167
if (this.props.privacy === 'private' || this.props.privacy === 'direct') {

app/javascript/mastodon/features/compose/containers/compose_form_container.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const mapStateToProps = state => ({
2222
caretPosition: state.getIn(['compose', 'caretPosition']),
2323
preselectDate: state.getIn(['compose', 'preselectDate']),
2424
is_submitting: state.getIn(['compose', 'is_submitting']),
25+
is_changing_upload: state.getIn(['compose', 'is_changing_upload']),
2526
is_uploading: state.getIn(['compose', 'is_uploading']),
2627
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
2728
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,

app/javascript/mastodon/reducers/compose.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const initialState = ImmutableMap({
5151
in_reply_to: null,
5252
is_composing: false,
5353
is_submitting: false,
54+
is_changing_upload: false,
5455
is_uploading: false,
5556
progress: 0,
5657
media_attachments: ImmutableList(),
@@ -79,6 +80,7 @@ function clearAll(state) {
7980
map.set('spoiler', false);
8081
map.set('spoiler_text', '');
8182
map.set('is_submitting', false);
83+
map.set('is_changing_upload', false);
8284
map.set('in_reply_to', null);
8385
map.set('privacy', state.get('default_privacy'));
8486
map.set('sensitive', false);
@@ -248,13 +250,15 @@ export default function compose(state = initialState, action) {
248250
map.set('idempotencyKey', uuid());
249251
});
250252
case COMPOSE_SUBMIT_REQUEST:
251-
case COMPOSE_UPLOAD_CHANGE_REQUEST:
252253
return state.set('is_submitting', true);
254+
case COMPOSE_UPLOAD_CHANGE_REQUEST:
255+
return state.set('is_changing_upload', true);
253256
case COMPOSE_SUBMIT_SUCCESS:
254257
return clearAll(state);
255258
case COMPOSE_SUBMIT_FAIL:
256-
case COMPOSE_UPLOAD_CHANGE_FAIL:
257259
return state.set('is_submitting', false);
260+
case COMPOSE_UPLOAD_CHANGE_FAIL:
261+
return state.set('is_changing_upload', false);
258262
case COMPOSE_UPLOAD_REQUEST:
259263
return state.set('is_uploading', true);
260264
case COMPOSE_UPLOAD_SUCCESS:
@@ -300,7 +304,7 @@ export default function compose(state = initialState, action) {
300304
return insertEmoji(state, action.position, action.emoji, action.needsSpace);
301305
case COMPOSE_UPLOAD_CHANGE_SUCCESS:
302306
return state
303-
.set('is_submitting', false)
307+
.set('is_changing_upload', false)
304308
.update('media_attachments', list => list.map(item => {
305309
if (item.get('id') === action.media.id) {
306310
return fromJS(action.media);

0 commit comments

Comments
 (0)