From 604ebdd24af7ec1178373e84a96fe1e07d6c1e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 24 Aug 2024 00:45:45 +0200 Subject: [PATCH] Handle sensitive and spoiler separately when writing a post MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/components/status-content.tsx | 2 +- .../chats/components/chat-message.tsx | 1 - .../compose/components/compose-form.tsx | 38 +++-------- .../compose/components/spoiler-button.tsx | 6 +- .../compose/components/spoiler-input.tsx | 65 +++++-------------- .../report/components/status-check-box.tsx | 1 - src/locales/en.json | 8 +-- src/locales/pl.json | 8 +-- src/reducers/compose.ts | 11 +--- 9 files changed, 38 insertions(+), 102 deletions(-) diff --git a/src/components/status-content.tsx b/src/components/status-content.tsx index cb37cfb3b..dbd823c0f 100644 --- a/src/components/status-content.tsx +++ b/src/components/status-content.tsx @@ -188,7 +188,7 @@ const StatusContent: React.FC = React.memo(({ if (spoilerText) { output.push( - + {expandable && ( - - - + ); }); diff --git a/src/features/report/components/status-check-box.tsx b/src/features/report/components/status-check-box.tsx index 98906d8e9..f55b2f2a1 100644 --- a/src/features/report/components/status-check-box.tsx +++ b/src/features/report/components/status-check-box.tsx @@ -63,7 +63,6 @@ const StatusCheckBox: React.FC = ({ id, disabled }) => { media={status.media_attachments} height={110} onOpenMedia={noop} - visible /> ); } diff --git a/src/locales/en.json b/src/locales/en.json index 426f42f11..663fea586 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -485,11 +485,9 @@ "compose_form.schedule": "Schedule", "compose_form.scheduled_statuses.click_here": "Click here", "compose_form.scheduled_statuses.message": "You have scheduled posts. {click_here} to see them.", - "compose_form.spoiler.marked": "Text is hidden behind warning", - "compose_form.spoiler.unmarked": "Text is not hidden", - "compose_form.spoiler_placeholder": "Write your warning here (optional)", - "compose_form.spoiler_remove": "Remove sensitive", - "compose_form.spoiler_title": "Sensitive content", + "compose_form.spoiler.marked": "Media is marked as sensitive", + "compose_form.spoiler.unmarked": "Media is not marked as sensitive", + "compose_form.spoiler_placeholder": "Subject (optional)", "confirmation_modal.cancel": "Cancel", "confirmations.admin.deactivate_user.confirm": "Deactivate @{name}", "confirmations.admin.deactivate_user.heading": "Deactivate @{acct}", diff --git a/src/locales/pl.json b/src/locales/pl.json index 5c695bb93..576f40d98 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -485,11 +485,9 @@ "compose_form.schedule": "Zaplanuj", "compose_form.scheduled_statuses.click_here": "Naciśnij tutaj", "compose_form.scheduled_statuses.message": "Masz zaplanowane wpisy. {click_here}, aby je zobaczyć.", - "compose_form.spoiler.marked": "Tekst jest ukryty za ostrzeżeniem", - "compose_form.spoiler.unmarked": "Tekst nie jest ukryty", - "compose_form.spoiler_placeholder": "Wprowadź swoje ostrzeżenie o zawartości", - "compose_form.spoiler_remove": "Usuń zaznaczenie jako wrażliwe", - "compose_form.spoiler_title": "Treści wrażliwe", + "compose_form.spoiler.marked": "Media są oznaczone jako wrażliwe", + "compose_form.spoiler.unmarked": "Media nie są oznaczone jako wrażliwe", + "compose_form.spoiler_placeholder": "Temat (nieobowiązkowy)", "confirmation_modal.cancel": "Anuluj", "confirmations.admin.deactivate_user.confirm": "Dezaktywuj @{name}", "confirmations.admin.deactivate_user.heading": "Dezaktywuj @{acct}", diff --git a/src/reducers/compose.ts b/src/reducers/compose.ts index 3d7a8478f..6d2ff6afe 100644 --- a/src/reducers/compose.ts +++ b/src/reducers/compose.ts @@ -105,7 +105,6 @@ const ReducerCompose = ImmutableRecord({ resetFileKey: null as number | null, schedule: null as Date | null, sensitive: false, - spoiler: false, spoiler_text: '', spoilerTextMap: ImmutableMap(), suggestions: ImmutableList(), @@ -165,7 +164,7 @@ const appendMedia = (compose: Compose, media: MediaAttachment, defaultSensitive? map.set('resetFileKey', Math.floor((Math.random() * 0x10000))); map.set('idempotencyKey', uuid()); - if (prevSize === 0 && (defaultSensitive || compose.spoiler)) { + if (prevSize === 0 && (defaultSensitive || compose.sensitive)) { map.set('sensitive', true); } }); @@ -293,9 +292,7 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | Me })); case COMPOSE_SPOILERNESS_CHANGE: return updateCompose(state, action.composeId, compose => compose.withMutations(map => { - map.set('spoiler_text', ''); - map.set('spoiler', !compose.spoiler); - map.set('sensitive', !compose.spoiler); + map.set('sensitive', !compose.sensitive); map.set('idempotencyKey', uuid()); })); case COMPOSE_SPOILER_TEXT_CHANGE: @@ -342,7 +339,6 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | Me map.set('idempotencyKey', uuid()); map.set('content_type', defaultCompose.content_type); if (action.preserveSpoilers && action.status.spoiler_text) { - map.set('spoiler', true); map.set('sensitive', true); map.set('spoiler_text', action.status.spoiler_text); } @@ -367,7 +363,6 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | Me map.set('caretPosition', null); map.set('idempotencyKey', uuid()); map.set('content_type', defaultCompose.content_type); - map.set('spoiler', false); map.set('spoiler_text', ''); if (action.status.visibility === 'group') { @@ -484,10 +479,8 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | Me } if (action.status.spoiler_text.length > 0) { - map.set('spoiler', true); map.set('spoiler_text', action.status.spoiler_text); } else { - map.set('spoiler', false); map.set('spoiler_text', ''); }