From 74155432cda16615c14f7b23222a622ed83992bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 19 Jul 2023 00:34:06 +0200 Subject: [PATCH 1/2] Add option to preserve spoilers text when replying 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 | 3 +++ app/soapbox/actions/settings.ts | 1 + app/soapbox/features/forms/index.tsx | 1 + app/soapbox/features/preferences/index.tsx | 10 ++++++++++ app/soapbox/reducers/compose.ts | 5 +++++ 5 files changed, 20 insertions(+) diff --git a/app/soapbox/actions/compose.ts b/app/soapbox/actions/compose.ts index a8bec65ee..edec9382c 100644 --- a/app/soapbox/actions/compose.ts +++ b/app/soapbox/actions/compose.ts @@ -144,6 +144,7 @@ interface ComposeReplyAction { status: Status account: Account explicitAddressing: boolean + preserveSpoilers: boolean } const replyCompose = (status: Status) => @@ -151,6 +152,7 @@ const replyCompose = (status: Status) => const state = getState(); const instance = state.instance; const { explicitAddressing } = getFeatures(instance); + const preserveSpoilers = !!getSettings(state).get('preserveSpoilers'); const action: ComposeReplyAction = { type: COMPOSE_REPLY, @@ -158,6 +160,7 @@ const replyCompose = (status: Status) => status: status, account: state.accounts.get(state.me)!, explicitAddressing, + preserveSpoilers, }; dispatch(action); diff --git a/app/soapbox/actions/settings.ts b/app/soapbox/actions/settings.ts index f72ec5e96..1e5c241d1 100644 --- a/app/soapbox/actions/settings.ts +++ b/app/soapbox/actions/settings.ts @@ -44,6 +44,7 @@ const defaultSettings = ImmutableMap({ explanationBox: true, autoloadTimelines: true, autoloadMore: true, + preserveSpoilers: false, systemFont: false, demetricator: false, diff --git a/app/soapbox/features/forms/index.tsx b/app/soapbox/features/forms/index.tsx index 564280c9b..df779ef02 100644 --- a/app/soapbox/features/forms/index.tsx +++ b/app/soapbox/features/forms/index.tsx @@ -118,6 +118,7 @@ export const Checkbox: React.FC = (props) => ( ); interface ISelectDropdown { + className?: string label?: React.ReactNode hint?: React.ReactNode items: Record diff --git a/app/soapbox/features/preferences/index.tsx b/app/soapbox/features/preferences/index.tsx index 09ea08eea..cd10fd45a 100644 --- a/app/soapbox/features/preferences/index.tsx +++ b/app/soapbox/features/preferences/index.tsx @@ -136,6 +136,7 @@ const Preferences = () => { }> ) => onSelectChange(event, ['locale'])} @@ -144,6 +145,7 @@ const Preferences = () => { }> ) => onSelectChange(event, ['displayMedia'])} @@ -153,6 +155,7 @@ const Preferences = () => { {features.privacyScopes && ( }> ) => onSelectChange(event, ['defaultPrivacy'])} @@ -163,12 +166,19 @@ const Preferences = () => { {features.richText && ( }> ) => onSelectChange(event, ['defaultContentType'])} /> )} + + {features.spoilers && ( + }> + + + )} diff --git a/app/soapbox/reducers/compose.ts b/app/soapbox/reducers/compose.ts index b5fefa4d1..8478cff28 100644 --- a/app/soapbox/reducers/compose.ts +++ b/app/soapbox/reducers/compose.ts @@ -312,6 +312,11 @@ export default function compose(state = initialState, action: ComposeAction | Me map.set('caretPosition', null); 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); + } })); case COMPOSE_EVENT_REPLY: return updateCompose(state, action.id, compose => compose.withMutations(map => { From f555128d682064c01c084d6da190585d7fada54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 19 Jul 2023 00:35:02 +0200 Subject: [PATCH 2/2] Update en.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/locales/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app/soapbox/locales/en.json b/app/soapbox/locales/en.json index c5808be64..bfd15580a 100644 --- a/app/soapbox/locales/en.json +++ b/app/soapbox/locales/en.json @@ -1196,6 +1196,7 @@ "preferences.fields.language_label": "Display Language", "preferences.fields.media_display_label": "Sensitive content", "preferences.fields.missing_description_modal_label": "Show confirmation dialog before sending a post without media descriptions", + "preferences.fields.preserve_spoilers_label": "Preserve content warning when replying", "preferences.fields.privacy_label": "Default post privacy", "preferences.fields.reduce_motion_label": "Reduce motion in animations", "preferences.fields.system_font_label": "Use system's default font",