[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 <me@prplecake.com> Co-committed-by: prplecake <me@prplecake.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { expandSpoilers, disableSwiping } from 'flavours/glitch/initial_state';
|
import { disableSwiping } from 'flavours/glitch/initial_state';
|
||||||
|
|
||||||
import { openModal } from './modal';
|
import { openModal } from './modal';
|
||||||
|
|
||||||
@@ -7,18 +7,9 @@ export const LOCAL_SETTING_DELETE = 'LOCAL_SETTING_DELETE';
|
|||||||
|
|
||||||
export function checkDeprecatedLocalSettings() {
|
export function checkDeprecatedLocalSettings() {
|
||||||
return (dispatch, getState) => {
|
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']);
|
const local_swipe_to_change_columns = getState().getIn(['local_settings', 'swipe_to_change_columns']);
|
||||||
let changed_settings = [];
|
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 !== null && local_swipe_to_change_columns !== undefined) {
|
||||||
if (local_swipe_to_change_columns === !disableSwiping) {
|
if (local_swipe_to_change_columns === !disableSwiping) {
|
||||||
dispatch(deleteLocalSetting(['swipe_to_change_columns']));
|
dispatch(deleteLocalSetting(['swipe_to_change_columns']));
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||||||
|
|
||||||
|
|
||||||
// Our imports
|
// Our imports
|
||||||
import { expandSpoilers } from 'flavours/glitch/initial_state';
|
|
||||||
|
|
||||||
import DeprecatedLocalSettingsPageItem from './deprecated_item';
|
|
||||||
import LocalSettingsPageItem from './item';
|
import LocalSettingsPageItem from './item';
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
@@ -308,35 +305,21 @@ class LocalSettingsPage extends PureComponent {
|
|||||||
</LocalSettingsPageItem>
|
</LocalSettingsPageItem>
|
||||||
<section>
|
<section>
|
||||||
<h2><FormattedMessage id='settings.content_warnings_unfold_opts' defaultMessage='Auto-unfolding options' /></h2>
|
<h2><FormattedMessage id='settings.content_warnings_unfold_opts' defaultMessage='Auto-unfolding options' /></h2>
|
||||||
<DeprecatedLocalSettingsPageItem
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['content_warnings', 'auto_unfold']}
|
||||||
|
onChange={onChange}
|
||||||
id='mastodon-settings--content_warnings-auto_unfold'
|
id='mastodon-settings--content_warnings-auto_unfold'
|
||||||
value={expandSpoilers}
|
|
||||||
>
|
>
|
||||||
<FormattedMessage id='settings.enable_content_warnings_auto_unfold' defaultMessage='Automatically unfold content-warnings' />
|
<FormattedMessage id='settings.enable_content_warnings_auto_unfold' defaultMessage='Automatically unfold content-warnings' />
|
||||||
<span className='hint'>
|
</LocalSettingsPageItem>
|
||||||
<FormattedMessage
|
|
||||||
id='settings.deprecated_setting'
|
|
||||||
defaultMessage="This setting is now controlled from Mastodon's {settings_page_link}"
|
|
||||||
values={{
|
|
||||||
settings_page_link: (
|
|
||||||
<span>
|
|
||||||
<FormattedMessage
|
|
||||||
id='settings.shared_settings_link'
|
|
||||||
defaultMessage='user preferences'
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</DeprecatedLocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
<LocalSettingsPageItem
|
||||||
settings={settings}
|
settings={settings}
|
||||||
item={['content_warnings', 'filter']}
|
item={['content_warnings', 'filter']}
|
||||||
id='mastodon-settings--content_warnings-auto_unfold'
|
id='mastodon-settings--content_warnings-auto_unfold'
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
dependsOn={[['content_warnings', 'auto_unfold']]}
|
||||||
placeholder={intl.formatMessage(messages.regexp)}
|
placeholder={intl.formatMessage(messages.regexp)}
|
||||||
disabled={!expandSpoilers}
|
|
||||||
>
|
>
|
||||||
<FormattedMessage id='settings.content_warnings_filter' defaultMessage='Content warnings to not automatically unfold:' />
|
<FormattedMessage id='settings.content_warnings_filter' defaultMessage='Content warnings to not automatically unfold:' />
|
||||||
</LocalSettingsPageItem>
|
</LocalSettingsPageItem>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const initialState = ImmutableMap({
|
|||||||
tag_misleading_links: true,
|
tag_misleading_links: true,
|
||||||
rewrite_mentions: 'no',
|
rewrite_mentions: 'no',
|
||||||
content_warnings : ImmutableMap({
|
content_warnings : ImmutableMap({
|
||||||
|
auto_unfold : false,
|
||||||
filter : null,
|
filter : null,
|
||||||
media_outside: true,
|
media_outside: true,
|
||||||
shared_state : true,
|
shared_state : true,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { expandSpoilers } from 'flavours/glitch/initial_state';
|
function _autoUnfoldCW(spoiler_text, settings) {
|
||||||
|
if (!settings.getIn(['content_warnings', 'auto_unfold']))
|
||||||
function _autoUnfoldCW(spoiler_text, skip_unfold_regex) {
|
|
||||||
if (!expandSpoilers)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const skip_unfold_regex = settings.getIn(['content_warnings', 'filter']);
|
||||||
|
|
||||||
if (!skip_unfold_regex)
|
if (!skip_unfold_regex)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -20,12 +20,12 @@ function _autoUnfoldCW(spoiler_text, skip_unfold_regex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function autoHideCW(settings, spoiler_text) {
|
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) {
|
export function autoUnfoldCW(settings, status) {
|
||||||
if (!status)
|
if (!status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return _autoUnfoldCW(status.get('spoiler_text'), settings.getIn(['content_warnings', 'filter']));
|
return _autoUnfoldCW(status.get('spoiler_text'), settings);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user