* Add aliases for some WebUI routes that were renamed in #16171 Accounts and statuses routes need more work as they use different parameters. * Add aliases for /statuses/* routes * Add aliases for /accounts/* WebUI routes Does not correctly set the “active” state on the navigation tabs but this is a minor issue. * Fix some routes * Fix /accounts/:id/{media,followers,following} not loading on legacy routespull/1609/head
parent
a0d4129893
commit
11502ae46e
|
@ -158,7 +158,7 @@ export function submitCompose(routerHistory) {
|
|||
'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
|
||||
},
|
||||
}).then(function (response) {
|
||||
if (routerHistory && routerHistory.location.pathname === '/publish' && window.history.state) {
|
||||
if (routerHistory && (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new') && window.history.state) {
|
||||
routerHistory.goBack();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import { connect } from 'react-redux';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import PropTypes from 'prop-types';
|
||||
import { lookupAccount } from 'mastodon/actions/accounts';
|
||||
import { lookupAccount, fetchAccount } from 'mastodon/actions/accounts';
|
||||
import { expandAccountMediaTimeline } from '../../actions/timelines';
|
||||
import LoadingIndicator from 'mastodon/components/loading_indicator';
|
||||
import Column from '../ui/components/column';
|
||||
|
@ -17,8 +17,8 @@ import MissingIndicator from 'mastodon/components/missing_indicator';
|
|||
import { openModal } from 'mastodon/actions/modal';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
const mapStateToProps = (state, { params: { acct } }) => {
|
||||
const accountId = state.getIn(['accounts_map', acct]);
|
||||
const mapStateToProps = (state, { params: { acct, id } }) => {
|
||||
const accountId = id || state.getIn(['accounts_map', acct]);
|
||||
|
||||
if (!accountId) {
|
||||
return {
|
||||
|
@ -64,7 +64,8 @@ class AccountGallery extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
params: PropTypes.shape({
|
||||
acct: PropTypes.string.isRequired,
|
||||
acct: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
}).isRequired,
|
||||
accountId: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
|
@ -82,8 +83,9 @@ class AccountGallery extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
_load () {
|
||||
const { accountId, dispatch } = this.props;
|
||||
const { accountId, isAccount, dispatch } = this.props;
|
||||
|
||||
if (!isAccount) dispatch(fetchAccount(accountId));
|
||||
dispatch(expandAccountMediaTimeline(accountId));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ import { connectTimeline, disconnectTimeline } from 'mastodon/actions/timelines'
|
|||
|
||||
const emptyList = ImmutableList();
|
||||
|
||||
const mapStateToProps = (state, { params: { acct }, withReplies = false }) => {
|
||||
const accountId = state.getIn(['accounts_map', acct]);
|
||||
const mapStateToProps = (state, { params: { acct, id }, withReplies = false }) => {
|
||||
const accountId = id || state.getIn(['accounts_map', acct]);
|
||||
|
||||
if (!accountId) {
|
||||
return {
|
||||
|
@ -58,7 +58,8 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
params: PropTypes.shape({
|
||||
acct: PropTypes.string.isRequired,
|
||||
acct: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
}).isRequired,
|
||||
accountId: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
|
|
|
@ -7,6 +7,7 @@ import { debounce } from 'lodash';
|
|||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import {
|
||||
lookupAccount,
|
||||
fetchAccount,
|
||||
fetchFollowers,
|
||||
expandFollowers,
|
||||
} from '../../actions/accounts';
|
||||
|
@ -19,8 +20,8 @@ import ScrollableList from '../../components/scrollable_list';
|
|||
import MissingIndicator from 'mastodon/components/missing_indicator';
|
||||
import TimelineHint from 'mastodon/components/timeline_hint';
|
||||
|
||||
const mapStateToProps = (state, { params: { acct } }) => {
|
||||
const accountId = state.getIn(['accounts_map', acct]);
|
||||
const mapStateToProps = (state, { params: { acct, id } }) => {
|
||||
const accountId = id || state.getIn(['accounts_map', acct]);
|
||||
|
||||
if (!accountId) {
|
||||
return {
|
||||
|
@ -53,7 +54,8 @@ class Followers extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
params: PropTypes.shape({
|
||||
acct: PropTypes.string.isRequired,
|
||||
acct: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
}).isRequired,
|
||||
accountId: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
|
@ -68,8 +70,9 @@ class Followers extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
_load () {
|
||||
const { accountId, dispatch } = this.props;
|
||||
const { accountId, isAccount, dispatch } = this.props;
|
||||
|
||||
if (!isAccount) dispatch(fetchAccount(accountId));
|
||||
dispatch(fetchFollowers(accountId));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { debounce } from 'lodash';
|
|||
import LoadingIndicator from '../../components/loading_indicator';
|
||||
import {
|
||||
lookupAccount,
|
||||
fetchAccount,
|
||||
fetchFollowing,
|
||||
expandFollowing,
|
||||
} from '../../actions/accounts';
|
||||
|
@ -19,8 +20,8 @@ import ScrollableList from '../../components/scrollable_list';
|
|||
import MissingIndicator from 'mastodon/components/missing_indicator';
|
||||
import TimelineHint from 'mastodon/components/timeline_hint';
|
||||
|
||||
const mapStateToProps = (state, { params: { acct } }) => {
|
||||
const accountId = state.getIn(['accounts_map', acct]);
|
||||
const mapStateToProps = (state, { params: { acct, id } }) => {
|
||||
const accountId = id || state.getIn(['accounts_map', acct]);
|
||||
|
||||
if (!accountId) {
|
||||
return {
|
||||
|
@ -53,7 +54,8 @@ class Following extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
params: PropTypes.shape({
|
||||
acct: PropTypes.string.isRequired,
|
||||
acct: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
}).isRequired,
|
||||
accountId: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
|
@ -68,8 +70,9 @@ class Following extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
_load () {
|
||||
const { accountId, dispatch } = this.props;
|
||||
const { accountId, isAccount, dispatch } = this.props;
|
||||
|
||||
if (!isAccount) dispatch(fetchAccount(accountId));
|
||||
dispatch(fetchFollowing(accountId));
|
||||
}
|
||||
|
||||
|
|
|
@ -154,10 +154,10 @@ class SwitchingColumnsArea extends React.PureComponent {
|
|||
<WrappedRoute path='/getting-started' component={GettingStarted} content={children} />
|
||||
<WrappedRoute path='/keyboard-shortcuts' component={KeyboardShortcuts} content={children} />
|
||||
|
||||
<WrappedRoute path='/home' component={HomeTimeline} content={children} />
|
||||
<WrappedRoute path='/public' exact component={PublicTimeline} content={children} />
|
||||
<WrappedRoute path='/public/local' exact component={CommunityTimeline} content={children} />
|
||||
<WrappedRoute path='/conversations' component={DirectTimeline} content={children} />
|
||||
<WrappedRoute path={['/home', '/timelines/home']} component={HomeTimeline} content={children} />
|
||||
<WrappedRoute path={['/public', '/timelines/public']} exact component={PublicTimeline} content={children} />
|
||||
<WrappedRoute path={['/public/local', '/timelines/public/local']} exact component={CommunityTimeline} content={children} />
|
||||
<WrappedRoute path={['/conversations', '/timelines/direct']} component={DirectTimeline} content={children} />
|
||||
<WrappedRoute path='/tags/:id' component={HashtagTimeline} content={children} />
|
||||
<WrappedRoute path='/lists/:id' component={ListTimeline} content={children} />
|
||||
<WrappedRoute path='/notifications' component={Notifications} content={children} />
|
||||
|
@ -169,17 +169,24 @@ class SwitchingColumnsArea extends React.PureComponent {
|
|||
<WrappedRoute path='/start' component={FollowRecommendations} content={children} />
|
||||
<WrappedRoute path='/search' component={Search} content={children} />
|
||||
<WrappedRoute path='/directory' component={Directory} content={children} />
|
||||
<WrappedRoute path='/publish' component={Compose} content={children} />
|
||||
<WrappedRoute path={['/publish', '/statuses/new']} component={Compose} content={children} />
|
||||
|
||||
<WrappedRoute path='/@:acct' exact component={AccountTimeline} content={children} />
|
||||
<WrappedRoute path='/@:acct/with_replies' component={AccountTimeline} content={children} componentParams={{ withReplies: true }} />
|
||||
<WrappedRoute path='/@:acct/followers' component={Followers} content={children} />
|
||||
<WrappedRoute path='/@:acct/following' component={Following} content={children} />
|
||||
<WrappedRoute path='/@:acct/media' component={AccountGallery} content={children} />
|
||||
<WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
|
||||
<WrappedRoute path={['/@:acct/with_replies', '/accounts/:id/with_replies']} component={AccountTimeline} content={children} componentParams={{ withReplies: true }} />
|
||||
<WrappedRoute path={['/@:acct/followers', '/accounts/:id/followers']} component={Followers} content={children} />
|
||||
<WrappedRoute path={['/@:acct/following', '/accounts/:id/following']} component={Following} content={children} />
|
||||
<WrappedRoute path={['/@:acct/media', '/accounts/:id/media']} component={AccountGallery} content={children} />
|
||||
<WrappedRoute path='/@:acct/:statusId' exact component={Status} content={children} />
|
||||
<WrappedRoute path='/@:acct/:statusId/reblogs' component={Reblogs} content={children} />
|
||||
<WrappedRoute path='/@:acct/:statusId/favourites' component={Favourites} content={children} />
|
||||
|
||||
{/* Legacy routes, cannot be easily factored with other routes because they share a param name */}
|
||||
<WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} />
|
||||
<WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} />
|
||||
<WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} />
|
||||
<WrappedRoute path='/statuses/:statusId/reblogs' component={Reblogs} content={children} />
|
||||
<WrappedRoute path='/statuses/:statusId/favourites' component={Favourites} content={children} />
|
||||
|
||||
<WrappedRoute path='/follow_requests' component={FollowRequests} content={children} />
|
||||
<WrappedRoute path='/blocks' component={Blocks} content={children} />
|
||||
<WrappedRoute path='/domain_blocks' component={DomainBlocks} content={children} />
|
||||
|
|
Loading…
Reference in New Issue