Handle /statuses/new route instead of just redirecting

This commit is contained in:
Alex Gleason 2021-10-15 15:30:24 -05:00
parent 966f0e84e4
commit f22037d51e
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,33 @@
import React from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
import PropTypes from 'prop-types';
import { openModal } from '../../actions/modal';
const mapDispatchToProps = dispatch => ({
onLoad: (text) => {
dispatch(openModal('COMPOSE'));
},
});
export default @connect(null, mapDispatchToProps)
class NewStatus extends React.Component {
static propTypes = {
onLoad: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.props.onLoad();
}
render() {
return (
<Redirect to='/' />
);
}
}

View File

@ -2,7 +2,6 @@ import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom'; import { Redirect } from 'react-router-dom';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { openComposeWithText } from '../../actions/compose'; import { openComposeWithText } from '../../actions/compose';
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
@ -14,7 +13,7 @@ const mapDispatchToProps = dispatch => ({
}); });
export default @connect(null, mapDispatchToProps) export default @connect(null, mapDispatchToProps)
class Share extends ImmutablePureComponent { class Share extends React.Component {
static propTypes = { static propTypes = {
onShare: PropTypes.func.isRequired, onShare: PropTypes.func.isRequired,

View File

@ -112,6 +112,7 @@ import {
ProfileHoverCard, ProfileHoverCard,
RegisterInvite, RegisterInvite,
Share, Share,
NewStatus,
} from './util/async-components'; } from './util/async-components';
// Dummy import, to make sure that <Status /> ends up in the application bundle. // Dummy import, to make sure that <Status /> ends up in the application bundle.
@ -239,7 +240,6 @@ class SwitchingColumnsArea extends React.PureComponent {
<Redirect from='/web/:path1/:path2/:path3' to='/:path1/:path2/:path3' /> <Redirect from='/web/:path1/:path2/:path3' to='/:path1/:path2/:path3' />
<Redirect from='/web/:path1/:path2' to='/:path1/:path2' /> <Redirect from='/web/:path1/:path2' to='/:path1/:path2' />
<Redirect from='/web/:path' to='/:path' /> <Redirect from='/web/:path' to='/:path' />
<Redirect from='/statuses/new' to='/' />
<Redirect from='/timelines/home' to='/' /> <Redirect from='/timelines/home' to='/' />
<Redirect from='/timelines/public/local' to='/timeline/local' /> <Redirect from='/timelines/public/local' to='/timeline/local' />
<Redirect from='/timelines/public' to='/timeline/fediverse' /> <Redirect from='/timelines/public' to='/timeline/fediverse' />
@ -292,6 +292,7 @@ class SwitchingColumnsArea extends React.PureComponent {
<WrappedRoute path='/@:username/posts/:statusId/reactions/:reaction?' page={DefaultPage} component={Reactions} content={children} /> <WrappedRoute path='/@:username/posts/:statusId/reactions/:reaction?' page={DefaultPage} component={Reactions} content={children} />
<Redirect from='/@:username/:statusId' to='/@:username/posts/:statusId' /> <Redirect from='/@:username/:statusId' to='/@:username/posts/:statusId' />
<WrappedRoute path='/statuses/new' page={DefaultPage} component={NewStatus} content={children} exact />
<WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} /> <WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
<WrappedRoute path='/scheduled_statuses' page={DefaultPage} component={ScheduledStatuses} content={children} /> <WrappedRoute path='/scheduled_statuses' page={DefaultPage} component={ScheduledStatuses} content={children} />

View File

@ -413,3 +413,7 @@ export function RegisterInvite() {
export function Share() { export function Share() {
return import(/* webpackChunkName: "features/share" */'../../share'); return import(/* webpackChunkName: "features/share" */'../../share');
} }
export function NewStatus() {
return import(/* webpackChunkName: "features/new_status" */'../../new_status');
}