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] 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 a8bec65ee9..edec9382c2 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 f72ec5e962..1e5c241d13 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 564280c9bb..df779ef02b 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 09ea08eea0..cd10fd45ac 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 b5fefa4d1b..8478cff28b 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 => {