From 3fbe0d38afb07db8f5b81d1ae0e3647c6c0d72fa Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 29 Mar 2021 15:15:35 -0500 Subject: [PATCH] Redirect account URLs like `/@9v5bmXkCYkqU30gp9s` to their username, `/@alex@spinster.xyz` --- app/soapbox/pages/profile_page.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/soapbox/pages/profile_page.js b/app/soapbox/pages/profile_page.js index 980f8ee6b..091df531f 100644 --- a/app/soapbox/pages/profile_page.js +++ b/app/soapbox/pages/profile_page.js @@ -13,6 +13,7 @@ import ProfileMediaPanel from '../features/ui/components/profile_media_panel'; import { acctFull } from 'soapbox/utils/accounts'; import { getFeatures } from 'soapbox/utils/features'; import { makeGetAccount } from '../selectors'; +import { Redirect } from 'react-router-dom'; const mapStateToProps = (state, { params: { username }, withReplies = false }) => { const accounts = state.getIn(['accounts']); @@ -32,11 +33,20 @@ const mapStateToProps = (state, { params: { username }, withReplies = false }) = //Children components fetch information + let realAccount; + if (!account) { + const maybeAccount = accounts.get(username); + if (maybeAccount) { + realAccount = maybeAccount; + } + } + return { account: accountId ? getAccount(state, accountId) : account, accountId, accountUsername, features: getFeatures(state.get('instance')), + realAccount, }; }; @@ -50,9 +60,13 @@ class ProfilePage extends ImmutablePureComponent { }; render() { - const { children, accountId, account, accountUsername, features } = this.props; + const { children, accountId, account, accountUsername, features, realAccount } = this.props; const bg = account ? account.getIn(['customizations', 'background']) : undefined; + if (realAccount) { + return ; + } + return (
{account &&