Use options rather than a boolean

This prepares for a third option that would restrict privacy to
privacyPreference(replyPrivacy, sideArmBasePrivacy)
lolsob-rspec
Thibaut Girka 2018-07-11 22:49:07 +02:00 committed by ThibG
parent b169f2df3b
commit 1a3e119ef7
3 changed files with 11 additions and 2 deletions

View File

@ -51,6 +51,9 @@ import { wrap } from 'flavours/glitch/util/redux_helpers';
// State mapping. // State mapping.
function mapStateToProps (state) { function mapStateToProps (state) {
const inReplyTo = state.getIn(['compose', 'in_reply_to']); const inReplyTo = state.getIn(['compose', 'in_reply_to']);
const replyPrivacy = inReplyTo ? state.getIn(['statuses', inReplyTo, 'visibility']) : null;
const sideArmBasePrivacy = state.getIn(['local_settings', 'side_arm']);
const sideArmPrivacy = (state.getIn(['local_settings', 'side_arm_reply_mode']) === 'copy' ? replyPrivacy : null) || sideArmBasePrivacy;
return { return {
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','), acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']).toArray().join(','),
advancedOptions: state.getIn(['compose', 'advanced_options']), advancedOptions: state.getIn(['compose', 'advanced_options']),
@ -67,7 +70,7 @@ function mapStateToProps (state) {
replyAccount: inReplyTo ? state.getIn(['statuses', inReplyTo, 'account']) : null, replyAccount: inReplyTo ? state.getIn(['statuses', inReplyTo, 'account']) : null,
replyContent: inReplyTo ? state.getIn(['statuses', inReplyTo, 'contentHtml']) : null, replyContent: inReplyTo ? state.getIn(['statuses', inReplyTo, 'contentHtml']) : null,
resetFileKey: state.getIn(['compose', 'resetFileKey']), resetFileKey: state.getIn(['compose', 'resetFileKey']),
sideArm: (state.getIn(['local_settings', 'side_arm_auto']) ? state.getIn(['compose', 'reply_privacy']) : null) || state.getIn(['local_settings', 'side_arm']), sideArm: sideArmPrivacy,
sensitive: state.getIn(['compose', 'sensitive']), sensitive: state.getIn(['compose', 'sensitive']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
spoiler: state.getIn(['compose', 'spoiler']), spoiler: state.getIn(['compose', 'spoiler']),

View File

@ -14,6 +14,8 @@ const messages = defineMessages({
layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' }, layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' },
layout_mobile: { id: 'layout.single', defaultMessage: 'Mobile' }, layout_mobile: { id: 'layout.single', defaultMessage: 'Mobile' },
side_arm_none: { id: 'settings.side_arm.none', defaultMessage: 'None' }, side_arm_none: { id: 'settings.side_arm.none', defaultMessage: 'None' },
side_arm_keep: { id: 'settings.side_arm_reply_mode.keep', defaultMessage: 'Keep secondary toot button to set privacy' },
side_arm_copy: { id: 'settings.side_arm_reply_mode.copy', defaultMessage: 'Copy privacy setting of the toot being replied to' },
}); });
@injectIntl @injectIntl
@ -80,6 +82,10 @@ export default class LocalSettingsPage extends React.PureComponent {
settings={settings} settings={settings}
item={['side_arm_reply_mode']} item={['side_arm_reply_mode']}
id='mastodon-settings--side_arm_reply_mode' id='mastodon-settings--side_arm_reply_mode'
options={[
{ value: 'keep', message: intl.formatMessage(messages.side_arm_keep) },
{ value: 'copy', message: intl.formatMessage(messages.side_arm_copy) }
]}
onChange={onChange} onChange={onChange}
> >
<FormattedMessage id='settings.side_arm_reply_mode' defaultMessage='When replying to a toot:' /> <FormattedMessage id='settings.side_arm_reply_mode' defaultMessage='When replying to a toot:' />

View File

@ -10,7 +10,7 @@ const initialState = ImmutableMap({
stretch : true, stretch : true,
navbar_under : false, navbar_under : false,
side_arm : 'none', side_arm : 'none',
side_arm_auto : false, side_arm_reply_mode : 'keep',
collapsed : ImmutableMap({ collapsed : ImmutableMap({
enabled : true, enabled : true,
auto : ImmutableMap({ auto : ImmutableMap({