From 02106153ecbe3de078a3dc3bea5a13775bb87cc5 Mon Sep 17 00:00:00 2001 From: prplecake Date: Wed, 14 May 2025 17:23:29 +0000 Subject: [PATCH] [feature] Re-enable auto-unfold CW setting (#46) Fixes #45 Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/46 Co-authored-by: prplecake Co-committed-by: prplecake --- .../flavours/glitch/actions/local_settings.js | 11 +------ .../features/local_settings/page/index.jsx | 29 ++++--------------- .../glitch/reducers/local_settings.js | 1 + .../flavours/glitch/utils/content_warning.js | 12 ++++---- 4 files changed, 14 insertions(+), 39 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/local_settings.js b/app/javascript/flavours/glitch/actions/local_settings.js index f2878daa5..da7033b75 100644 --- a/app/javascript/flavours/glitch/actions/local_settings.js +++ b/app/javascript/flavours/glitch/actions/local_settings.js @@ -1,4 +1,4 @@ -import { expandSpoilers, disableSwiping } from 'flavours/glitch/initial_state'; +import { disableSwiping } from 'flavours/glitch/initial_state'; import { openModal } from './modal'; @@ -7,18 +7,9 @@ export const LOCAL_SETTING_DELETE = 'LOCAL_SETTING_DELETE'; export function checkDeprecatedLocalSettings() { return (dispatch, getState) => { - const local_auto_unfold = getState().getIn(['local_settings', 'content_warnings', 'auto_unfold']); const local_swipe_to_change_columns = getState().getIn(['local_settings', 'swipe_to_change_columns']); let changed_settings = []; - if (local_auto_unfold !== null && local_auto_unfold !== undefined) { - if (local_auto_unfold === expandSpoilers) { - dispatch(deleteLocalSetting(['content_warnings', 'auto_unfold'])); - } else { - changed_settings.push('user_setting_expand_spoilers'); - } - } - if (local_swipe_to_change_columns !== null && local_swipe_to_change_columns !== undefined) { if (local_swipe_to_change_columns === !disableSwiping) { dispatch(deleteLocalSetting(['swipe_to_change_columns'])); diff --git a/app/javascript/flavours/glitch/features/local_settings/page/index.jsx b/app/javascript/flavours/glitch/features/local_settings/page/index.jsx index a565ad5da..fac9838c3 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.jsx +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.jsx @@ -8,9 +8,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; // Our imports -import { expandSpoilers } from 'flavours/glitch/initial_state'; - -import DeprecatedLocalSettingsPageItem from './deprecated_item'; import LocalSettingsPageItem from './item'; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -308,35 +305,21 @@ class LocalSettingsPage extends PureComponent {

- - - - - - ), - }} - /> - - + diff --git a/app/javascript/flavours/glitch/reducers/local_settings.js b/app/javascript/flavours/glitch/reducers/local_settings.js index 39a910ef6..16d31afb4 100644 --- a/app/javascript/flavours/glitch/reducers/local_settings.js +++ b/app/javascript/flavours/glitch/reducers/local_settings.js @@ -23,6 +23,7 @@ const initialState = ImmutableMap({ tag_misleading_links: true, rewrite_mentions: 'no', content_warnings : ImmutableMap({ + auto_unfold : false, filter : null, media_outside: true, shared_state : true, diff --git a/app/javascript/flavours/glitch/utils/content_warning.js b/app/javascript/flavours/glitch/utils/content_warning.js index 91d452baa..18105981f 100644 --- a/app/javascript/flavours/glitch/utils/content_warning.js +++ b/app/javascript/flavours/glitch/utils/content_warning.js @@ -1,9 +1,9 @@ -import { expandSpoilers } from 'flavours/glitch/initial_state'; - -function _autoUnfoldCW(spoiler_text, skip_unfold_regex) { - if (!expandSpoilers) +function _autoUnfoldCW(spoiler_text, settings) { + if (!settings.getIn(['content_warnings', 'auto_unfold'])) return false; + const skip_unfold_regex = settings.getIn(['content_warnings', 'filter']); + if (!skip_unfold_regex) return true; @@ -20,12 +20,12 @@ function _autoUnfoldCW(spoiler_text, skip_unfold_regex) { } export function autoHideCW(settings, spoiler_text) { - return !_autoUnfoldCW(spoiler_text, settings.getIn(['content_warnings', 'filter'])); + return !_autoUnfoldCW(spoiler_text, settings); } export function autoUnfoldCW(settings, status) { if (!status) return false; - return _autoUnfoldCW(status.get('spoiler_text'), settings.getIn(['content_warnings', 'filter'])); + return _autoUnfoldCW(status.get('spoiler_text'), settings); }