From 9d2739d74da26b725f03eb5a19a93c6041714be7 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 28 Aug 2018 14:10:26 +0200 Subject: [PATCH] Add a setting to automatically unfold all content warnings --- .../flavours/glitch/components/status.js | 1 + .../features/local_settings/navigation/index.js | 17 ++++++++++++----- .../features/local_settings/page/index.js | 13 +++++++++++++ .../flavours/glitch/features/status/index.js | 4 ++-- .../flavours/glitch/reducers/local_settings.js | 3 +++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 1ac5a4b3e6d..e0d591ff69a 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -56,6 +56,7 @@ export default class Status extends ImmutablePureComponent { state = { isCollapsed: false, autoCollapsed: false, + isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']), } // Avoid checking props that are functions (and whose equality will always diff --git a/app/javascript/flavours/glitch/features/local_settings/navigation/index.js b/app/javascript/flavours/glitch/features/local_settings/navigation/index.js index fc2167c0c00..0c1040290e9 100644 --- a/app/javascript/flavours/glitch/features/local_settings/navigation/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/navigation/index.js @@ -10,6 +10,7 @@ import LocalSettingsNavigationItem from './item'; const messages = defineMessages({ general: { id: 'settings.general', defaultMessage: 'General' }, + content_warnings: { id: 'settings.content_warnings', defaultMessage: 'Content Warnings' }, collapsed: { id: 'settings.collapsed_statuses', defaultMessage: 'Collapsed toots' }, media: { id: 'settings.media', defaultMessage: 'Media' }, preferences: { id: 'settings.preferences', defaultMessage: 'Preferences' }, @@ -42,25 +43,31 @@ export default class LocalSettingsNavigation extends React.PureComponent { active={index === 1} index={1} onNavigate={onNavigate} - title={intl.formatMessage(messages.collapsed)} + title={intl.formatMessage(messages.content_warnings)} /> + diff --git a/app/javascript/flavours/glitch/features/local_settings/page/index.js b/app/javascript/flavours/glitch/features/local_settings/page/index.js index 1e61c67c0bb..37396d970cf 100644 --- a/app/javascript/flavours/glitch/features/local_settings/page/index.js +++ b/app/javascript/flavours/glitch/features/local_settings/page/index.js @@ -122,6 +122,19 @@ export default class LocalSettingsPage extends React.PureComponent { ), + ({ onChange, settings }) => ( +
+

+ + + +
+ ), ({ onChange, settings }) => (

diff --git a/app/javascript/flavours/glitch/features/status/index.js b/app/javascript/flavours/glitch/features/status/index.js index 1fceaa5ea76..060f2f345fd 100644 --- a/app/javascript/flavours/glitch/features/status/index.js +++ b/app/javascript/flavours/glitch/features/status/index.js @@ -82,8 +82,8 @@ export default class Status extends ImmutablePureComponent { state = { fullscreen: false, - isExpanded: false, - threadExpanded: null, + isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']), + threadExpanded: undefined, }; componentWillMount () { diff --git a/app/javascript/flavours/glitch/reducers/local_settings.js b/app/javascript/flavours/glitch/reducers/local_settings.js index ebe0b12924e..ce33cac8349 100644 --- a/app/javascript/flavours/glitch/reducers/local_settings.js +++ b/app/javascript/flavours/glitch/reducers/local_settings.js @@ -14,6 +14,9 @@ const initialState = ImmutableMap({ show_reply_count : false, always_show_spoilers_field: false, confirm_missing_media_description: false, + content_warnings : ImmutableMap({ + auto_unfold : false, + }), collapsed : ImmutableMap({ enabled : true, auto : ImmutableMap({