The modifications you made are somewhat janky; for instance, editing a toot with an existing content warning makes the UI look very weird and doesn't quite work. Glitch already has a feature for this, so simply turn it on by default. This should do the same thing. Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/1 Co-authored-by: julia <midnight@trainwit.ch> Co-committed-by: julia <midnight@trainwit.ch>
29 lines
912 B
JavaScript
29 lines
912 B
JavaScript
import { injectIntl, defineMessages } from 'react-intl';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { changeComposeSpoilerness } from '../../../actions/compose';
|
|
import TextIconButton from '../components/text_icon_button';
|
|
|
|
const messages = defineMessages({
|
|
marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
|
|
unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
|
|
});
|
|
|
|
const mapStateToProps = (state, { intl }) => ({
|
|
label: 'CW',
|
|
title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked),
|
|
active: state.getIn(['compose', 'spoiler']),
|
|
ariaControls: 'cw-spoiler-input',
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
onClick () {
|
|
dispatch(changeComposeSpoilerness());
|
|
},
|
|
|
|
});
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
|