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 = { state = {
isCollapsed: false, isCollapsed: false,
autoCollapsed: false, autoCollapsed: false,
isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']),
} }
// Avoid checking props that are functions (and whose equality will always // Avoid checking props that are functions (and whose equality will always

View File

@ -10,6 +10,7 @@ import LocalSettingsNavigationItem from './item';
const messages = defineMessages({ const messages = defineMessages({
general: { id: 'settings.general', defaultMessage: 'General' }, general: { id: 'settings.general', defaultMessage: 'General' },
content_warnings: { id: 'settings.content_warnings', defaultMessage: 'Content Warnings' },
collapsed: { id: 'settings.collapsed_statuses', defaultMessage: 'Collapsed toots' }, collapsed: { id: 'settings.collapsed_statuses', defaultMessage: 'Collapsed toots' },
media: { id: 'settings.media', defaultMessage: 'Media' }, media: { id: 'settings.media', defaultMessage: 'Media' },
preferences: { id: 'settings.preferences', defaultMessage: 'Preferences' }, preferences: { id: 'settings.preferences', defaultMessage: 'Preferences' },
@ -42,25 +43,31 @@ export default class LocalSettingsNavigation extends React.PureComponent {
active={index === 1} active={index === 1}
index={1} index={1}
onNavigate={onNavigate} onNavigate={onNavigate}
title={intl.formatMessage(messages.collapsed)} title={intl.formatMessage(messages.content_warnings)}
/> />
<LocalSettingsNavigationItem <LocalSettingsNavigationItem
active={index === 2} active={index === 2}
index={2} index={2}
onNavigate={onNavigate} onNavigate={onNavigate}
title={intl.formatMessage(messages.media)} title={intl.formatMessage(messages.collapsed)}
/> />
<LocalSettingsNavigationItem <LocalSettingsNavigationItem
active={index === 3} active={index === 3}
href='/settings/preferences'
index={3} index={3}
onNavigate={onNavigate}
title={intl.formatMessage(messages.media)}
/>
<LocalSettingsNavigationItem
active={index === 4}
href='/settings/preferences'
index={4}
icon='cog' icon='cog'
title={intl.formatMessage(messages.preferences)} title={intl.formatMessage(messages.preferences)}
/> />
<LocalSettingsNavigationItem <LocalSettingsNavigationItem
active={index === 4} active={index === 5}
className='close' className='close'
index={4} index={5}
onNavigate={onClose} onNavigate={onClose}
title={intl.formatMessage(messages.close)} title={intl.formatMessage(messages.close)}
/> />

View File

@ -122,6 +122,19 @@ export default class LocalSettingsPage extends React.PureComponent {
</section> </section>
</div> </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 }) => ( ({ onChange, settings }) => (
<div className='glitch local-settings__page collapsed'> <div className='glitch local-settings__page collapsed'>
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1> <h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>

View File

@ -82,8 +82,8 @@ export default class Status extends ImmutablePureComponent {
state = { state = {
fullscreen: false, fullscreen: false,
isExpanded: false, isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']),
threadExpanded: null, threadExpanded: undefined,
}; };
componentWillMount () { componentWillMount () {

View File

@ -14,6 +14,9 @@ const initialState = ImmutableMap({
show_reply_count : false, show_reply_count : false,
always_show_spoilers_field: false, always_show_spoilers_field: false,
confirm_missing_media_description: false, confirm_missing_media_description: false,
content_warnings : ImmutableMap({
auto_unfold : false,
}),
collapsed : ImmutableMap({ collapsed : ImmutableMap({
enabled : true, enabled : true,
auto : ImmutableMap({ auto : ImmutableMap({