Skip to content

Commit

Permalink
[WiP] Prepare for secondary post button
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 22, 2024
1 parent 6496d36 commit 993b492
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/javascript/flavours/glitch/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function directCompose(account, routerHistory) {
};
}

export function submitCompose(routerHistory) {
export function submitCompose(routerHistory, overridePrivacy = null) {
return function (dispatch, getState) {
let status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
Expand Down Expand Up @@ -228,7 +228,7 @@ export function submitCompose(routerHistory) {
media_attributes,
sensitive: getState().getIn(['compose', 'sensitive']) || (spoilerText.length > 0 && media.size !== 0),
spoiler_text: spoilerText,
visibility: getState().getIn(['compose', 'privacy']),
visibility: overridePrivacy || getState().getIn(['compose', 'privacy']),
poll: getState().getIn(['compose', 'poll'], null),
language: getState().getIn(['compose', 'language']),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ComposeForm extends ImmutablePureComponent {
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (isOnlyWhitespace && !anyMedia));
};

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

this.props.onSubmit(this.props.history || null);
this.props.onSubmit(this.props.history || null, overridePrivacy);

if (e) {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(changeCompose(text));
},

onSubmit (router) {
dispatch(submitCompose(router));
onSubmit (router, overridePrivacy = null) {
dispatch(submitCompose(router, overridePrivacy));
},

onClearSuggestions () {
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/flavours/glitch/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,10 @@ body > [data-popper-placement] {
&__submit {
display: flex;
align-items: center;
flex: 1 1 auto;
flex: 1 0 100%; // glitch: always on its own line
max-width: 100%;
overflow: hidden;
gap: 5px; // glitch: handle secondary post privacy
}

&__buttons {
Expand Down

0 comments on commit 993b492

Please sign in to comment.