From 31005aad12c6a915a00501765a6dab25878326cb Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Nov 2022 21:22:17 +0100 Subject: [PATCH] Add the ability to edit media attachment metadata for any unattached media (#20402) --- .../mastodon/features/compose/components/upload.js | 7 +++---- .../features/compose/containers/upload_container.js | 1 - app/javascript/mastodon/reducers/compose.js | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/upload.js b/app/javascript/mastodon/features/compose/components/upload.js index 97ac54da9..b08307ade 100644 --- a/app/javascript/mastodon/features/compose/components/upload.js +++ b/app/javascript/mastodon/features/compose/components/upload.js @@ -17,7 +17,6 @@ export default class Upload extends ImmutablePureComponent { media: ImmutablePropTypes.map.isRequired, onUndo: PropTypes.func.isRequired, onOpenFocalPoint: PropTypes.func.isRequired, - isEditingStatus: PropTypes.bool.isRequired, }; handleUndoClick = e => { @@ -31,7 +30,7 @@ export default class Upload extends ImmutablePureComponent { } render () { - const { media, isEditingStatus } = this.props; + const { media } = this.props; const focusX = media.getIn(['meta', 'focus', 'x']); const focusY = media.getIn(['meta', 'focus', 'y']); const x = ((focusX / 2) + .5) * 100; @@ -44,10 +43,10 @@ export default class Upload extends ImmutablePureComponent {
- {!isEditingStatus && ()} + {!!media.get('unattached') && ()}
- {(media.get('description') || '').length === 0 && !isEditingStatus && ( + {(media.get('description') || '').length === 0 && !!media.get('unattached') && (
diff --git a/app/javascript/mastodon/features/compose/containers/upload_container.js b/app/javascript/mastodon/features/compose/containers/upload_container.js index 1108aec30..05cd2ecc1 100644 --- a/app/javascript/mastodon/features/compose/containers/upload_container.js +++ b/app/javascript/mastodon/features/compose/containers/upload_container.js @@ -5,7 +5,6 @@ import { submitCompose } from '../../../actions/compose'; const mapStateToProps = (state, { id }) => ({ media: state.getIn(['compose', 'media_attachments']).find(item => item.get('id') === id), - isEditingStatus: state.getIn(['compose', 'id']) !== null, }); const mapDispatchToProps = dispatch => ({ diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index ad384bd0b..afb8b40c1 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -135,7 +135,7 @@ function appendMedia(state, media, file) { if (media.get('type') === 'image') { media = media.set('file', file); } - map.update('media_attachments', list => list.push(media)); + map.update('media_attachments', list => list.push(media.set('unattached', true))); map.set('is_uploading', false); map.set('is_processing', false); map.set('resetFileKey', Math.floor((Math.random() * 0x10000))); @@ -446,7 +446,7 @@ export default function compose(state = initialState, action) { map.set('text', action.raw_text || unescapeHTML(expandMentions(action.status))); map.set('in_reply_to', action.status.get('in_reply_to_id')); map.set('privacy', action.status.get('visibility')); - map.set('media_attachments', action.status.get('media_attachments')); + map.set('media_attachments', action.status.get('media_attachments').map((media) => media.set('unattached', true))); map.set('focusDate', new Date()); map.set('caretPosition', null); map.set('idempotencyKey', uuid());