2022-06-07 11:46:21 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import { changeComposeSensitivity } from 'soapbox/actions/compose';
|
2022-06-07 11:55:34 -07:00
|
|
|
import { FormGroup, Checkbox } from 'soapbox/components/ui';
|
2022-06-07 11:46:21 -07:00
|
|
|
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
marked: { id: 'compose_form.sensitive.marked', defaultMessage: 'Media is marked as sensitive' },
|
|
|
|
unmarked: { id: 'compose_form.sensitive.unmarked', defaultMessage: 'Media is not marked as sensitive' },
|
|
|
|
});
|
|
|
|
|
|
|
|
/** Button to mark own media as sensitive. */
|
|
|
|
const SensitiveButton: React.FC = () => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const dispatch = useAppDispatch();
|
|
|
|
|
|
|
|
const active = useAppSelector(state => state.compose.get('sensitive') === true);
|
|
|
|
const disabled = useAppSelector(state => state.compose.get('spoiler') === true);
|
|
|
|
|
|
|
|
const onClick = () => {
|
|
|
|
dispatch(changeComposeSensitivity());
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2022-06-07 11:55:34 -07:00
|
|
|
<div className='px-2.5 py-1'>
|
|
|
|
<FormGroup
|
|
|
|
labelText={<FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />}
|
|
|
|
labelTitle={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
|
|
|
>
|
|
|
|
<Checkbox
|
2022-06-07 11:46:21 -07:00
|
|
|
name='mark-sensitive'
|
|
|
|
checked={active}
|
|
|
|
onChange={onClick}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
2022-06-07 11:55:34 -07:00
|
|
|
</FormGroup>
|
2022-06-07 11:46:21 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SensitiveButton;
|