Browse Source

compose: force local-only quotes of local-only

Co-authored-by: Jessica Stokes <hello@jessicastokes.net>
pull/1371/head
Misty De Meo 2 months ago
parent
commit
e50fe8ba18
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C
  1. 8
      app/javascript/mastodon/features/compose/components/compose_form.jsx
  2. 8
      app/javascript/mastodon/features/compose/containers/compose_form_container.js

8
app/javascript/mastodon/features/compose/components/compose_form.jsx

@ -67,6 +67,7 @@ class ComposeForm extends ImmutablePureComponent {
onChangeSpoilerText: PropTypes.func.isRequired, onChangeSpoilerText: PropTypes.func.isRequired,
onPaste: PropTypes.func.isRequired, onPaste: PropTypes.func.isRequired,
onPickEmoji: PropTypes.func.isRequired, onPickEmoji: PropTypes.func.isRequired,
disableFederation: PropTypes.func.isRequired,
autoFocus: PropTypes.bool, autoFocus: PropTypes.bool,
withoutNavigation: PropTypes.bool, withoutNavigation: PropTypes.bool,
anyMedia: PropTypes.bool, anyMedia: PropTypes.bool,
@ -192,6 +193,10 @@ class ComposeForm extends ImmutablePureComponent {
componentDidUpdate (prevProps) { componentDidUpdate (prevProps) {
this._updateFocusAndSelection(prevProps); this._updateFocusAndSelection(prevProps);
if (this.props.quoteOfLocalOnly && prevProps.quoteOfLocalOnly !== this.props.quoteOfLocalOnly) {
this.props.disableFederation();
}
} }
_updateFocusAndSelection = (prevProps) => { _updateFocusAndSelection = (prevProps) => {
@ -253,6 +258,7 @@ class ComposeForm extends ImmutablePureComponent {
render () { render () {
const { intl, onPaste, autoFocus, withoutNavigation, maxChars, isSubmitting } = this.props; const { intl, onPaste, autoFocus, withoutNavigation, maxChars, isSubmitting } = this.props;
const { highlighted } = this.state; const { highlighted } = this.state;
const disabled = this.props.quoteOfLocalOnly || this.props.isEditing;
return ( return (
<form className='compose-form' onSubmit={this.handleSubmit}> <form className='compose-form' onSubmit={this.handleSubmit}>
@ -265,7 +271,7 @@ class ComposeForm extends ImmutablePureComponent {
<div className='compose-form__dropdowns'> <div className='compose-form__dropdowns'>
<VisibilityButton disabled={this.props.isEditing} /> <VisibilityButton disabled={this.props.isEditing} />
<FederationDropdownContainer disabled={this.props.isEditing} /> <FederationDropdownContainer disabled={disabled} />
<LanguageDropdown /> <LanguageDropdown />
</div> </div>

8
app/javascript/mastodon/features/compose/containers/compose_form_container.js

@ -2,6 +2,7 @@ import { connect } from 'react-redux';
import { import {
changeCompose, changeCompose,
changeComposeFederation,
submitCompose, submitCompose,
clearComposeSuggestions, clearComposeSuggestions,
fetchComposeSuggestions, fetchComposeSuggestions,
@ -40,6 +41,9 @@ const mapStateToProps = state => ({
&& state.getIn(['compose', 'privacy']) === 'private' && state.getIn(['compose', 'privacy']) === 'private'
&& state.getIn(['statuses', state.getIn(['compose', 'quoted_status_id']), 'account']) !== me && state.getIn(['statuses', state.getIn(['compose', 'quoted_status_id']), 'account']) !== me
&& !state.getIn(['settings', 'dismissed_banners', PRIVATE_QUOTE_MODAL_ID]), && !state.getIn(['settings', 'dismissed_banners', PRIVATE_QUOTE_MODAL_ID]),
quoteOfLocalOnly:
!!state.getIn(['compose', 'quoted_status_id'])
&& state.getIn(['statuses', state.getIn(['compose', 'quoted_status_id']), 'local_only']),
isInReply: state.getIn(['compose', 'in_reply_to']) !== null, isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
lang: state.getIn(['compose', 'language']), lang: state.getIn(['compose', 'language']),
maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500), maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500),
@ -108,6 +112,10 @@ const mapDispatchToProps = (dispatch, props) => ({
dispatch(insertEmojiCompose(position, data, needsSpace)); dispatch(insertEmojiCompose(position, data, needsSpace));
}, },
disableFederation () {
dispatch(changeComposeFederation(false));
},
}); });
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm); export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);

Loading…
Cancel
Save