Add a setting to automatically unfold all content warnings

lolsob-rspec
Thibaut Girka 2018-08-28 14:10:26 +02:00 committed by ThibG
parent a3afd0791d
commit 02c32ad7af
5 changed files with 31 additions and 7 deletions

View File

@ -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

View File

@ -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)}
/>
<LocalSettingsNavigationItem
active={index === 2}
index={2}
onNavigate={onNavigate}
title={intl.formatMessage(messages.media)}
title={intl.formatMessage(messages.collapsed)}
/>
<LocalSettingsNavigationItem
active={index === 3}
href='/settings/preferences'
index={3}
onNavigate={onNavigate}
title={intl.formatMessage(messages.media)}
/>
<LocalSettingsNavigationItem
active={index === 4}
href='/settings/preferences'
index={4}
icon='cog'
title={intl.formatMessage(messages.preferences)}
/>
<LocalSettingsNavigationItem
active={index === 4}
active={index === 5}
className='close'
index={4}
index={5}
onNavigate={onClose}
title={intl.formatMessage(messages.close)}
/>

View File

@ -122,6 +122,19 @@ export default class LocalSettingsPage extends React.PureComponent {
</section>
</div>
),
({ onChange, settings }) => (
<div className='glitch local-settings__page content_warnings'>
<h1><FormattedMessage id='settings.content_warnings' defaultMessage='Content warnings' /></h1>
<LocalSettingsPageItem
settings={settings}
item={['content_warnings', 'auto_unfold']}
id='mastodon-settings--content_warnings-auto_unfold'
onChange={onChange}
>
<FormattedMessage id='settings.enable_content_warnings_auto_unfold' defaultMessage='Automatically unfold content-warnings' />
</LocalSettingsPageItem>
</div>
),
({ onChange, settings }) => (
<div className='glitch local-settings__page collapsed'>
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>

View File

@ -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 () {

View File

@ -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({