Skip to content

Commit

Permalink
Add a new key-binding
Browse files Browse the repository at this point in the history
* Tooting with [Shift] will be done in unlisted
  • Loading branch information
GenbuHase authored and atsu1125 committed Nov 10, 2022
1 parent 96198e2 commit 676073a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function directCompose(account, routerHistory) {
};
};

export function submitCompose(routerHistory) {
export function submitCompose(routerHistory, privacy) {
return function (dispatch, getState) {
const status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
Expand All @@ -156,6 +156,8 @@ export function submitCompose(routerHistory) {
return;
}

if (privacy) dispatch(changeComposeVisibility(privacy));

dispatch(submitComposeRequest());

api(getState).request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ComposeForm extends ImmutablePureComponent {

handleKeyDown = (e) => {
if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
this.handleSubmit();
this.handleSubmit(null, e.shiftKey ? 'unlisted' : null);
}
}

Expand All @@ -93,7 +93,7 @@ class ComposeForm extends ImmutablePureComponent {
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (isOnlyWhitespace && !anyMedia));
}

handleSubmit = () => {
handleSubmit = (e, privacy) => {
if (this.props.text !== this.autosuggestTextarea.textarea.value) {
// Something changed the text inside the textarea (e.g. browser extensions like Grammarly)
// Update the state to match the current text
Expand All @@ -104,7 +104,7 @@ class ComposeForm extends ImmutablePureComponent {
return;
}

this.props.onSubmit(this.context.router ? this.context.router.history : null);
this.props.onSubmit(this.context.router ? this.context.router.history : null, privacy);
}

onSuggestionsClearRequested = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(changeCompose(text));
},

onSubmit (router) {
dispatch(submitCompose(router));
onSubmit (router, privacy) {
dispatch(submitCompose(router, privacy));
},

onClearSuggestions () {
Expand Down

0 comments on commit 676073a

Please sign in to comment.