Browse Source

[Glitch] Show compose form on delete & redraft when in mobile layout

Port 025fbb8285 to glitch-soc
closed-social-glitch-2
Thibaut Girka 6 years ago
committed by ThibG
parent
commit
130bdb5ee8
5 changed files with 15 additions and 11 deletions
  1. +5
    -1
      app/javascript/flavours/glitch/actions/statuses.js
  2. +2
    -2
      app/javascript/flavours/glitch/components/status_action_bar.js
  3. +3
    -3
      app/javascript/flavours/glitch/containers/status_container.js
  4. +2
    -2
      app/javascript/flavours/glitch/features/status/components/action_bar.js
  5. +3
    -3
      app/javascript/flavours/glitch/features/status/index.js

+ 5
- 1
app/javascript/flavours/glitch/actions/statuses.js View File

@ -79,7 +79,7 @@ export function redraft(status) {
};
};
export function deleteStatus(id, withRedraft = false) {
export function deleteStatus(id, router, withRedraft = false) {
return (dispatch, getState) => {
const status = getState().getIn(['statuses', id]);
@ -91,6 +91,10 @@ export function deleteStatus(id, withRedraft = false) {
if (withRedraft) {
dispatch(redraft(status));
if (!getState().getIn(['compose', 'mounted'])) {
router.push('/statuses/new');
}
}
}).catch(error => {
dispatch(deleteStatusFail(id, error));

+ 2
- 2
app/javascript/flavours/glitch/components/status_action_bar.js View File

@ -102,11 +102,11 @@ export default class StatusActionBar extends ImmutablePureComponent {
}
handleDeleteClick = () => {
this.props.onDelete(this.props.status);
this.props.onDelete(this.props.status, this.context.router.history);
}
handleRedraftClick = () => {
this.props.onDelete(this.props.status, true);
this.props.onDelete(this.props.status, this.context.router.history, true);
}
handlePinClick = () => {

+ 3
- 3
app/javascript/flavours/glitch/containers/status_container.js View File

@ -122,14 +122,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(openModal('EMBED', { url: status.get('url') }));
},
onDelete (status, withRedraft = false) {
onDelete (status, history, withRedraft = false) {
if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), withRedraft));
dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else {
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
}));
}
},

+ 2
- 2
app/javascript/flavours/glitch/features/status/components/action_bar.js View File

@ -70,11 +70,11 @@ export default class ActionBar extends React.PureComponent {
}
handleDeleteClick = () => {
this.props.onDelete(this.props.status);
this.props.onDelete(this.props.status, this.context.router.history);
}
handleRedraftClick = () => {
this.props.onDelete(this.props.status, true);
this.props.onDelete(this.props.status, this.context.router.history, true);
}
handleDirectClick = () => {

+ 3
- 3
app/javascript/flavours/glitch/features/status/index.js View File

@ -159,16 +159,16 @@ export default class Status extends ImmutablePureComponent {
}
}
handleDeleteClick = (status, withRedraft = false) => {
handleDeleteClick = (status, history, withRedraft = false) => {
const { dispatch, intl } = this.props;
if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), withRedraft));
dispatch(deleteStatus(status.get('id'), history, withRedraft));
} else {
dispatch(openModal('CONFIRM', {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
}));
}
}

Loading…
Cancel
Save