Let default post privacy be configurable

stable/1.0.x
Alex Gleason 2020-04-20 15:18:35 -05:00
rodzic 16d65f88f1
commit e761942ced
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 64 dodań i 21 usunięć

Wyświetl plik

@ -53,36 +53,66 @@ class Preferences extends ImmutablePureComponent {
dispatch(changeSetting(['theme'], e.target.value));
}
onDefaultPrivacyChange = e => {
const { dispatch } = this.props;
dispatch(changeSetting(['defaultPrivacy'], e.target.value));
}
render() {
const { settings, intl } = this.props;
return (
<Column icon='users' heading={intl.formatMessage(messages.heading)} backBtnSlim>
<form className='simple_form' onSubmit={this.handleSubmit}>
<fieldset disabled={this.state.isLoading}>
<div className='fields-group'>
<div className='input with_label select optional user_setting_theme'>
<div className='label_input'>
<label className='select optional' htmlFor='user_setting_theme'>Site theme</label>
<div className='label_input__wrapper'>
<select
className='select optional'
name='user[setting_theme]'
id='user_setting_theme'
onChange={this.onThemeChange}
defaultValue={settings.get('theme')}
>
{Object.keys(themes).map(theme => (
<option key={theme} value={theme}>
{themes[theme]}
</option>
))}
</select>
</div>
<div className='fields-group'>
<div className='input with_label select optional user_setting_theme'>
<div className='label_input'>
<label className='select optional' htmlFor='user_setting_theme'>Site theme</label>
<div className='label_input__wrapper'>
<select
className='select optional'
name='user[setting_theme]'
id='user_setting_theme'
onChange={this.onThemeChange}
defaultValue={settings.get('theme')}
>
{Object.keys(themes).map(theme => (
<option key={theme} value={theme}>
{themes[theme]}
</option>
))}
</select>
</div>
</div>
</div>
</fieldset>
</div>
<div className='fields-group'>
<div className='input with_floating_label radio_buttons optional user_setting_default_privacy'>
<div className='label_input'>
<label className='radio_buttons optional'>Post privacy</label>
<ul>
<li className='radio'>
<label htmlFor='user_setting_default_privacy_public'>
<input className='radio_buttons optional' type='radio' checked={settings.get('defaultPrivacy') === 'public'} onChange={this.onDefaultPrivacyChange} value='public' id='user_setting_default_privacy_public' />Public
<span className='hint'>Everyone can see</span>
</label>
</li>
<li className='radio'>
<label htmlFor='user_setting_default_privacy_unlisted'>
<input className='radio_buttons optional' type='radio' checked={settings.get('defaultPrivacy') === 'unlisted'} onChange={this.onDefaultPrivacyChange} value='unlisted' id='user_setting_default_privacy_unlisted' />Unlisted
<span className='hint'>Everyone can see, but not listed on public timelines</span>
</label>
</li>
<li className='radio'>
<label htmlFor='user_setting_default_privacy_private'>
<input className='radio_buttons optional' type='radio' checked={settings.get('defaultPrivacy') === 'private'} onChange={this.onDefaultPrivacyChange} value='private' id='user_setting_default_privacy_private' />Followers-only
<span className='hint'>Only show to followers</span>
</label>
</li>
</ul>
</div>
</div>
</div>
</form>
</Column>
);

Wyświetl plik

@ -39,6 +39,8 @@ import {
import { TIMELINE_DELETE } from '../actions/timelines';
import { STORE_HYDRATE } from '../actions/store';
import { REDRAFT } from '../actions/statuses';
import { ME_FETCH_SUCCESS } from '../actions/me';
import { SETTING_CHANGE, FE_NAME } from '../actions/settings';
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
import uuid from '../uuid';
import { unescapeHTML } from '../utils/html';
@ -368,6 +370,16 @@ export default function compose(state = initialState, action) {
return state.updateIn(['poll', 'options'], options => options.delete(action.index));
case COMPOSE_POLL_SETTINGS_CHANGE:
return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple));
case ME_FETCH_SUCCESS:
const me = fromJS(action.me);
const defaultPrivacy = me.getIn(['pleroma', 'settings_store', FE_NAME, 'defaultPrivacy']);
if (!defaultPrivacy) return state;
return state.set('default_privacy', defaultPrivacy).set('privacy', defaultPrivacy);
case SETTING_CHANGE:
const pathString = action.path.join(',');
if (pathString === 'defaultPrivacy')
return state.set('default_privacy', action.value).set('privacy', action.value);
return state;
default:
return state;
}

Wyświetl plik

@ -19,6 +19,7 @@ const initialState = ImmutableMap({
unfollowModal: false,
boostModal: false,
deleteModal: true,
defaultPrivacy: 'public',
theme: 'lime',
home: ImmutableMap({