From 81af0e64f1ea27d5a1ad0fea9d926b784a8a8c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 3 Aug 2022 23:55:14 +0200 Subject: [PATCH 1/2] Use different confirmation modal/snackbar text for post editing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/compose.ts | 7 ++++--- app/soapbox/features/ui/components/compose_modal.tsx | 11 ++++++++--- app/soapbox/locales/pl.json | 4 ++++ app/soapbox/reducers/compose.ts | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/soapbox/actions/compose.ts b/app/soapbox/actions/compose.ts index 450b2ef50..ad8439307 100644 --- a/app/soapbox/actions/compose.ts +++ b/app/soapbox/actions/compose.ts @@ -92,6 +92,7 @@ const messages = defineMessages({ exceededVideoDurationLimit: { id: 'upload_error.video_duration_limit', defaultMessage: 'Video exceeds the current duration limit ({limit} seconds)' }, scheduleError: { id: 'compose.invalid_schedule', defaultMessage: 'You must schedule a post at least 5 minutes out.' }, success: { id: 'compose.submit_success', defaultMessage: 'Your post was sent' }, + editSuccess: { id: 'compose.edit_success', defaultMessage: 'Your post was edited' }, uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' }, uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' }, view: { id: 'snackbar.view', defaultMessage: 'View' }, @@ -203,12 +204,12 @@ const directComposeById = (accountId: string) => dispatch(openModal('COMPOSE')); }; -const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, data: APIEntity, status: string) => { +const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, data: APIEntity, status: string, edit?: boolean) => { if (!dispatch || !getState) return; dispatch(insertIntoTagHistory(data.tags || [], status)); dispatch(submitComposeSuccess({ ...data })); - dispatch(snackbar.success(messages.success, messages.view, `/@${data.account.acct}/posts/${data.id}`)); + dispatch(snackbar.success(edit ? messages.editSuccess : messages.success, messages.view, `/@${data.account.acct}/posts/${data.id}`)); }; const needsDescriptions = (state: RootState) => { @@ -287,7 +288,7 @@ const submitCompose = (routerHistory?: History, force = false) => if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) { routerHistory.push('/messages'); } - handleComposeSubmit(dispatch, getState, data, status); + handleComposeSubmit(dispatch, getState, data, status, !!statusId); }).catch(function(error) { dispatch(submitComposeFail(error)); }); diff --git a/app/soapbox/features/ui/components/compose_modal.tsx b/app/soapbox/features/ui/components/compose_modal.tsx index 8b8abc342..edd5ea740 100644 --- a/app/soapbox/features/ui/components/compose_modal.tsx +++ b/app/soapbox/features/ui/components/compose_modal.tsx @@ -11,6 +11,7 @@ import ComposeFormContainer from '../../compose/containers/compose_form_containe const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, + discardConfirm: { id: 'confirmations.discard_edit.confirm', defaultMessage: 'Discard' }, }); interface IComposeModal { @@ -31,9 +32,13 @@ const ComposeModal: React.FC = ({ onClose }) => { if (composeText) { dispatch(openModal('CONFIRM', { icon: require('@tabler/icons/trash.svg'), - heading: , - message: , - confirm: intl.formatMessage(messages.confirm), + heading: statusId + ? + : , + message: statusId + ? + : , + confirm: intl.formatMessage(statusId ? messages.discardConfirm : messages.confirm), onConfirm: () => { dispatch(closeModal('COMPOSE')); dispatch(cancelReplyCompose()); diff --git a/app/soapbox/locales/pl.json b/app/soapbox/locales/pl.json index 7e578059d..8586cdcce 100644 --- a/app/soapbox/locales/pl.json +++ b/app/soapbox/locales/pl.json @@ -276,6 +276,7 @@ "compare_history_modal.header": "Historia edycji", "compose.character_counter.title": "Wykorzystano {chars} z {maxChars} znaków", "compose.invalid_schedule": "Musisz zaplanować wpis przynajmniej 5 minut wcześniej.", + "compose.edit_success": "Twój wpis został zedytowany", "compose.submit_success": "Twój wpis został wysłany", "compose_form.direct_message_warning": "Ten wpis będzie widoczny tylko dla wszystkich wspomnianych użytkowników.", "compose_form.hashtag_warning": "Ten wpis nie będzie widoczny pod podanymi hashtagami, ponieważ jest oznaczony jako niewidoczny. Tylko publiczne wpisy mogą zostać znalezione z użyciem hashtagów.", @@ -338,6 +339,9 @@ "confirmations.delete_list.confirm": "Usuń", "confirmations.delete_list.heading": "Usuń listę", "confirmations.delete_list.message": "Czy na pewno chcesz bezpowrotnie usunąć tą listę?", + "confirmations.discard_edit.confirm": "Odrzuć", + "confirmations.discard_edit.heading": "Odrzuć edycję wpisu", + "confirmations.discard_edit.message": "Czy na pewno chcesz odrzucić zmiany w tym wpisie?", "confirmations.domain_block.confirm": "Ukryj wszysyko z domeny", "confirmations.domain_block.heading": "Zablokuj {domain}", "confirmations.domain_block.message": "Czy na pewno chcesz zablokować całą domenę {domain}? Zwykle lepszym rozwiązaniem jest blokada lub wyciszenie kilku użytkowników.", diff --git a/app/soapbox/reducers/compose.ts b/app/soapbox/reducers/compose.ts index c15e26270..a6e3b94a0 100644 --- a/app/soapbox/reducers/compose.ts +++ b/app/soapbox/reducers/compose.ts @@ -444,7 +444,7 @@ export default function compose(state = ReducerRecord({ idempotencyKey: uuid(), map.set('content_type', action.contentType || 'text/plain'); map.set('quote', action.status.get('quote')); - if (action.v?.software === PLEROMA && !action.withRedraft && hasIntegerMediaIds(action.status)) { + if (action.v?.software === PLEROMA && action.withRedraft && hasIntegerMediaIds(action.status)) { map.set('media_attachments', ImmutableList()); } else { map.set('media_attachments', action.status.media_attachments); From 2ea76f74cfb840ff04ea7b0f9c7bb0ebd6bcf9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 4 Aug 2022 00:09:47 +0200 Subject: [PATCH 2/2] fix test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/ui/components/compose_modal.tsx | 8 ++++---- app/soapbox/locales/pl.json | 3 --- app/soapbox/reducers/__tests__/compose.test.ts | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/soapbox/features/ui/components/compose_modal.tsx b/app/soapbox/features/ui/components/compose_modal.tsx index edd5ea740..81a8c9254 100644 --- a/app/soapbox/features/ui/components/compose_modal.tsx +++ b/app/soapbox/features/ui/components/compose_modal.tsx @@ -11,7 +11,7 @@ import ComposeFormContainer from '../../compose/containers/compose_form_containe const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, - discardConfirm: { id: 'confirmations.discard_edit.confirm', defaultMessage: 'Discard' }, + cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' }, }); interface IComposeModal { @@ -33,12 +33,12 @@ const ComposeModal: React.FC = ({ onClose }) => { dispatch(openModal('CONFIRM', { icon: require('@tabler/icons/trash.svg'), heading: statusId - ? + ? : , message: statusId - ? + ? : , - confirm: intl.formatMessage(statusId ? messages.discardConfirm : messages.confirm), + confirm: intl.formatMessage(statusId ? messages.cancelEditing : messages.confirm), onConfirm: () => { dispatch(closeModal('COMPOSE')); dispatch(cancelReplyCompose()); diff --git a/app/soapbox/locales/pl.json b/app/soapbox/locales/pl.json index 8586cdcce..82bdc287c 100644 --- a/app/soapbox/locales/pl.json +++ b/app/soapbox/locales/pl.json @@ -339,9 +339,6 @@ "confirmations.delete_list.confirm": "Usuń", "confirmations.delete_list.heading": "Usuń listę", "confirmations.delete_list.message": "Czy na pewno chcesz bezpowrotnie usunąć tą listę?", - "confirmations.discard_edit.confirm": "Odrzuć", - "confirmations.discard_edit.heading": "Odrzuć edycję wpisu", - "confirmations.discard_edit.message": "Czy na pewno chcesz odrzucić zmiany w tym wpisie?", "confirmations.domain_block.confirm": "Ukryj wszysyko z domeny", "confirmations.domain_block.heading": "Zablokuj {domain}", "confirmations.domain_block.message": "Czy na pewno chcesz zablokować całą domenę {domain}? Zwykle lepszym rozwiązaniem jest blokada lub wyciszenie kilku użytkowników.", diff --git a/app/soapbox/reducers/__tests__/compose.test.ts b/app/soapbox/reducers/__tests__/compose.test.ts index bb6906c6d..b1cc01b58 100644 --- a/app/soapbox/reducers/__tests__/compose.test.ts +++ b/app/soapbox/reducers/__tests__/compose.test.ts @@ -44,6 +44,7 @@ describe('compose reducer', () => { type: actions.COMPOSE_SET_STATUS, status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))), v: { software: 'Pleroma' }, + withRedraft: true, }; const result = reducer(undefined, action);