From 188d66c9a81b508fd6c036aaff05048c47d1ea72 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 27 Sep 2021 07:23:48 +0200 Subject: [PATCH] [Glitch] Add aliases for WebUI routes that were renamed in #16171 Port 11502ae46e4813bc23aeb5d03093a01d53991ab8 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/actions/compose.js | 2 +- .../glitch/features/account_gallery/index.js | 12 +++++---- .../glitch/features/account_timeline/index.js | 7 ++--- .../glitch/features/followers/index.js | 11 +++++--- .../glitch/features/following/index.js | 11 +++++--- .../flavours/glitch/features/ui/index.js | 27 ++++++++++++------- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index ac6e7f0c4f4..96931546c0e 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -177,7 +177,7 @@ export function submitCompose(routerHistory) { }, }).then(function (response) { if (routerHistory - && routerHistory.location.pathname === '/publish' + && (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new') && window.history.state && !getState().getIn(['compose', 'advanced_options', 'threaded_mode'])) { routerHistory.goBack(); diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.js b/app/javascript/flavours/glitch/features/account_gallery/index.js index 508f49107c9..8df1bf4ca5e 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.js +++ b/app/javascript/flavours/glitch/features/account_gallery/index.js @@ -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 { fetchAccount } from 'flavours/glitch/actions/accounts'; +import { lookupAccount, fetchAccount } from 'flavours/glitch/actions/accounts'; import { expandAccountMediaTimeline } from 'flavours/glitch/actions/timelines'; import LoadingIndicator from 'flavours/glitch/components/loading_indicator'; import Column from 'flavours/glitch/features/ui/components/column'; @@ -16,8 +16,8 @@ import LoadMore from 'flavours/glitch/components/load_more'; import MissingIndicator from 'flavours/glitch/components/missing_indicator'; import { openModal } from 'flavours/glitch/actions/modal'; -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 { @@ -62,7 +62,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, @@ -79,8 +80,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)); } diff --git a/app/javascript/flavours/glitch/features/account_timeline/index.js b/app/javascript/flavours/glitch/features/account_timeline/index.js index 3d2bbb3b7ce..0d091579d6f 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/index.js +++ b/app/javascript/flavours/glitch/features/account_timeline/index.js @@ -19,8 +19,8 @@ import TimelineHint from 'flavours/glitch/components/timeline_hint'; 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 { @@ -56,7 +56,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, diff --git a/app/javascript/flavours/glitch/features/followers/index.js b/app/javascript/flavours/glitch/features/followers/index.js index 21e25b86983..978436dccc2 100644 --- a/app/javascript/flavours/glitch/features/followers/index.js +++ b/app/javascript/flavours/glitch/features/followers/index.js @@ -6,6 +6,7 @@ import { debounce } from 'lodash'; import LoadingIndicator from 'flavours/glitch/components/loading_indicator'; import { lookupAccount, + fetchAccount, fetchFollowers, expandFollowers, } from 'flavours/glitch/actions/accounts'; @@ -19,8 +20,8 @@ import MissingIndicator from 'flavours/glitch/components/missing_indicator'; import ScrollableList from 'flavours/glitch/components/scrollable_list'; import TimelineHint from 'flavours/glitch/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 { @@ -52,7 +53,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, @@ -66,8 +68,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)); } diff --git a/app/javascript/flavours/glitch/features/following/index.js b/app/javascript/flavours/glitch/features/following/index.js index c1d026d98d7..446a19894bf 100644 --- a/app/javascript/flavours/glitch/features/following/index.js +++ b/app/javascript/flavours/glitch/features/following/index.js @@ -6,6 +6,7 @@ import { debounce } from 'lodash'; import LoadingIndicator from 'flavours/glitch/components/loading_indicator'; import { lookupAccount, + fetchAccount, fetchFollowing, expandFollowing, } from 'flavours/glitch/actions/accounts'; @@ -19,8 +20,8 @@ import MissingIndicator from 'flavours/glitch/components/missing_indicator'; import ScrollableList from 'flavours/glitch/components/scrollable_list'; import TimelineHint from 'flavours/glitch/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 { @@ -52,7 +53,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, @@ -66,8 +68,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)); } diff --git a/app/javascript/flavours/glitch/features/ui/index.js b/app/javascript/flavours/glitch/features/ui/index.js index 4683f11cdc2..7ca1adf7cc4 100644 --- a/app/javascript/flavours/glitch/features/ui/index.js +++ b/app/javascript/flavours/glitch/features/ui/index.js @@ -200,10 +200,10 @@ class SwitchingColumnsArea extends React.PureComponent { - - - - + + + + @@ -215,17 +215,24 @@ class SwitchingColumnsArea extends React.PureComponent { - + - - - - - + + + + + + {/* Legacy routes, cannot be easily factored with other routes because they share a param name */} + + + + + +