mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 07:49:29 +00:00
[Glitch] Redirect on success for standalone compose
Port 7cf53dbf63 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -193,8 +193,9 @@ export function directCompose(account) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {null | string} overridePrivacy
|
* @param {null | string} overridePrivacy
|
||||||
|
* @param {undefined | Function} successCallback
|
||||||
*/
|
*/
|
||||||
export function submitCompose(overridePrivacy = null) {
|
export function submitCompose(overridePrivacy = null, successCallback = undefined) {
|
||||||
return function (dispatch, getState) {
|
return function (dispatch, getState) {
|
||||||
let status = getState().getIn(['compose', 'text'], '');
|
let status = getState().getIn(['compose', 'text'], '');
|
||||||
const media = getState().getIn(['compose', 'media_attachments']);
|
const media = getState().getIn(['compose', 'media_attachments']);
|
||||||
@@ -261,6 +262,9 @@ export function submitCompose(overridePrivacy = null) {
|
|||||||
|
|
||||||
dispatch(insertIntoTagHistory(response.data.tags, status));
|
dispatch(insertIntoTagHistory(response.data.tags, status));
|
||||||
dispatch(submitComposeSuccess({ ...response.data }));
|
dispatch(submitComposeSuccess({ ...response.data }));
|
||||||
|
if (typeof successCallback === 'function') {
|
||||||
|
successCallback(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
// To make the app more responsive, immediately push the status
|
// To make the app more responsive, immediately push the status
|
||||||
// into the columns
|
// into the columns
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class ComposeForm extends ImmutablePureComponent {
|
|||||||
singleColumn: PropTypes.bool,
|
singleColumn: PropTypes.bool,
|
||||||
lang: PropTypes.string,
|
lang: PropTypes.string,
|
||||||
maxChars: PropTypes.number,
|
maxChars: PropTypes.number,
|
||||||
|
redirectOnSuccess: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -358,7 +359,7 @@ class ComposeForm extends ImmutablePureComponent {
|
|||||||
>
|
>
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
this.props.isEditing ?
|
this.props.isEditing ?
|
||||||
messages.saveChanges :
|
messages.saveChanges :
|
||||||
(this.props.isInReply ? messages.reply : messages.publish)
|
(this.props.isInReply ? messages.reply : messages.publish)
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const mapStateToProps = state => ({
|
|||||||
maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500),
|
maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch, props) => ({
|
||||||
|
|
||||||
onChange (text) {
|
onChange (text) {
|
||||||
dispatch(changeCompose(text));
|
dispatch(changeCompose(text));
|
||||||
@@ -69,7 +69,11 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
modalProps: { overridePrivacy },
|
modalProps: { overridePrivacy },
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
dispatch(submitCompose(overridePrivacy));
|
dispatch(submitCompose(overridePrivacy, (status) => {
|
||||||
|
if (props.redirectOnSuccess) {
|
||||||
|
window.location.assign(status.url);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import ModalContainer from 'flavours/glitch/features/ui/containers/modal_contain
|
|||||||
|
|
||||||
const Compose = () => (
|
const Compose = () => (
|
||||||
<>
|
<>
|
||||||
<ComposeFormContainer autoFocus withoutNavigation />
|
<ComposeFormContainer autoFocus withoutNavigation redirectOnSuccess />
|
||||||
<AlertsController />
|
<AlertsController />
|
||||||
<ModalContainer />
|
<ModalContainer />
|
||||||
<LoadingBarContainer className='loading-bar' />
|
<LoadingBarContainer className='loading-bar' />
|
||||||
|
|||||||
Reference in New Issue
Block a user