Restore default post privacy/format settings
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
7c3d0c821b
commit
1f85803e7f
1 changed files with 37 additions and 13 deletions
|
@ -8,6 +8,7 @@ import { Form } from 'soapbox/components/ui';
|
||||||
import { SelectDropdown } from 'soapbox/features/forms';
|
import { SelectDropdown } from 'soapbox/features/forms';
|
||||||
import SettingToggle from 'soapbox/features/notifications/components/setting_toggle';
|
import SettingToggle from 'soapbox/features/notifications/components/setting_toggle';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useAppSelector } from 'soapbox/hooks';
|
||||||
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
import ThemeToggle from '../ui/components/theme-toggle';
|
import ThemeToggle from '../ui/components/theme-toggle';
|
||||||
|
|
||||||
|
@ -80,27 +81,24 @@ const messages = defineMessages({
|
||||||
display_media_default: { id: 'preferences.fields.display_media.default', defaultMessage: 'Hide media marked as sensitive' },
|
display_media_default: { id: 'preferences.fields.display_media.default', defaultMessage: 'Hide media marked as sensitive' },
|
||||||
display_media_hide_all: { id: 'preferences.fields.display_media.hide_all', defaultMessage: 'Always hide media' },
|
display_media_hide_all: { id: 'preferences.fields.display_media.hide_all', defaultMessage: 'Always hide media' },
|
||||||
display_media_show_all: { id: 'preferences.fields.display_media.show_all', defaultMessage: 'Always show media' },
|
display_media_show_all: { id: 'preferences.fields.display_media.show_all', defaultMessage: 'Always show media' },
|
||||||
|
privacy_public: { id: 'preferences.options.privacy_public', defaultMessage: 'Public' },
|
||||||
|
privacy_unlisted: { id: 'preferences.options.privacy_unlisted', defaultMessage: 'Unlisted' },
|
||||||
|
privacy_followers_only: { id: 'preferences.options.privacy_followers_only', defaultMessage: 'Followers-only' },
|
||||||
|
content_type_plaintext: { id: 'preferences.options.content_type_plaintext', defaultMessage: 'Plain text' },
|
||||||
|
content_type_markdown: { id: 'preferences.options.content_type_markdown', defaultMessage: 'Markdown' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const Preferences = () => {
|
const Preferences = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
// const features = useAppSelector((state) => getFeatures(state.get('instance')));
|
const features = useAppSelector((state) => getFeatures(state.instance));
|
||||||
const settings = useAppSelector((state) => getSettings(state));
|
const settings = useAppSelector((state) => getSettings(state));
|
||||||
|
|
||||||
const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, path: string[]) => {
|
const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, path: string[]) => {
|
||||||
dispatch(changeSetting(path, event.target.value, intl));
|
dispatch(changeSetting(path, event.target.value, intl));
|
||||||
};
|
};
|
||||||
|
|
||||||
// const onDefaultPrivacyChange = (e) => {
|
|
||||||
// dispatch(changeSetting(['defaultPrivacy'], e.target.value));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const onDefaultContentTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
// dispatch(changeSetting(['defaultContentType'], event.target.value));
|
|
||||||
// };
|
|
||||||
|
|
||||||
const onToggleChange = (key: string[], checked: boolean) => {
|
const onToggleChange = (key: string[], checked: boolean) => {
|
||||||
dispatch(changeSetting(key, checked, intl));
|
dispatch(changeSetting(key, checked, intl));
|
||||||
};
|
};
|
||||||
|
@ -111,6 +109,17 @@ const Preferences = () => {
|
||||||
show_all: intl.formatMessage(messages.display_media_show_all),
|
show_all: intl.formatMessage(messages.display_media_show_all),
|
||||||
}), []);
|
}), []);
|
||||||
|
|
||||||
|
const defaultPrivacyOptions = React.useMemo(() => ({
|
||||||
|
public: intl.formatMessage(messages.privacy_public),
|
||||||
|
unlisted: intl.formatMessage(messages.privacy_unlisted),
|
||||||
|
private: intl.formatMessage(messages.privacy_followers_only),
|
||||||
|
}), []);
|
||||||
|
|
||||||
|
const defaultContentTypeOptions = React.useMemo(() => ({
|
||||||
|
'text/plain': intl.formatMessage(messages.content_type_plaintext),
|
||||||
|
'text/markdown': intl.formatMessage(messages.content_type_markdown),
|
||||||
|
}), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<List>
|
<List>
|
||||||
|
@ -149,6 +158,22 @@ const Preferences = () => {
|
||||||
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => onSelectChange(event, ['displayMedia'])}
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => onSelectChange(event, ['displayMedia'])}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
|
{features.privacyScopes && <ListItem label={<FormattedMessage id='preferences.fields.privacy_label' defaultMessage='Default post privacy' />}>
|
||||||
|
<SelectDropdown
|
||||||
|
items={defaultPrivacyOptions}
|
||||||
|
defaultValue={settings.get('defaultPrivacy') as string | undefined}
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => onSelectChange(event, ['defaultPrivacy'])}
|
||||||
|
/>
|
||||||
|
</ListItem>}
|
||||||
|
|
||||||
|
{features.richText && <ListItem label={<FormattedMessage id='preferences.fields.content_type_label' defaultMessage='Default post format' />}>
|
||||||
|
<SelectDropdown
|
||||||
|
items={defaultContentTypeOptions}
|
||||||
|
defaultValue={settings.get('defaultContentType') as string | undefined}
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => onSelectChange(event, ['defaultContentType'])}
|
||||||
|
/>
|
||||||
|
</ListItem>}
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
{/* <FieldsGroup>
|
{/* <FieldsGroup>
|
||||||
|
@ -211,10 +236,9 @@ const Preferences = () => {
|
||||||
<SettingToggle settings={settings} settingPath={['deleteModal']} onChange={onToggleChange} />
|
<SettingToggle settings={settings} settingPath={['deleteModal']} onChange={onToggleChange} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
{/* <SettingsCheckbox
|
{/* <ListItem label={<FormattedMessage id='preferences.fields.missing_description_modal_label' defaultMessage='Show confirmation dialog before sending a post without media descriptions' />}>
|
||||||
label={<FormattedMessage id='preferences.fields.missing_description_modal_label' defaultMessage='Show confirmation dialog before sending a post without media descriptions' />}
|
<SettingToggle settings={settings} settingPath={['missingDescriptionModal']} onChange={onToggleChange} />
|
||||||
path={['missingDescriptionModal']}
|
</ListItem> */}
|
||||||
/> */}
|
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
<List>
|
<List>
|
||||||
|
|
Loading…
Reference in a new issue