Redirect account URLs like `/@9v5bmXkCYkqU30gp9s` to their username, `/@alex@spinster.xyz`

merge-requests/454/head
Alex Gleason 2021-03-29 15:15:35 -05:00
rodzic ad84e586f1
commit 3fbe0d38af
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -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 <Redirect to={`/@${realAccount.get('acct')}`} />;
}
return (
<div className={bg && `page page--customization page--${bg}` || 'page'}>
{account && <Helmet>