[Glitch] Change routing paths to use usernames in web UI

Port 52e5c07948 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Eugen Rochko
2021-09-26 05:46:13 +02:00
committed by Claire
parent 3622110778
commit a7f6524c6b
45 changed files with 385 additions and 198 deletions

View File

@@ -128,7 +128,7 @@ class Account extends ImmutablePureComponent {
<Permalink
className='account small'
href={account.get('url')}
to={`/accounts/${account.get('id')}`}
to={`/@${account.get('acct')}`}
>
<div className='account__avatar-wrapper'>
<Avatar
@@ -144,7 +144,7 @@ class Account extends ImmutablePureComponent {
) : (
<div className='account'>
<div className='account__wrapper'>
<Permalink key={account.get('id')} className='account__display-name' href={account.get('url')} to={`/accounts/${account.get('id')}`}>
<Permalink key={account.get('id')} className='account__display-name' title={account.get('acct')} href={account.get('url')} to={`/@${account.get('acct')}`}>
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
{mute_expires_at}
<DisplayName account={account} />

View File

@@ -82,7 +82,7 @@ export default class AvatarComposite extends React.PureComponent {
<a
href={account.get('url')}
target='_blank'
onClick={(e) => this.props.onAccountClick(account.get('id'), e)}
onClick={(e) => this.props.onAccountClick(account.get('acct'), e)}
title={`@${account.get('acct')}`}
key={account.get('id')}
>

View File

@@ -61,7 +61,7 @@ export default class DisplayName extends React.PureComponent {
<a
href={a.get('url')}
target='_blank'
onClick={(e) => onAccountClick(a.get('id'), e)}
onClick={(e) => onAccountClick(a.get('acct'), e)}
title={`@${a.get('acct')}`}
rel='noopener noreferrer'
>
@@ -76,7 +76,7 @@ export default class DisplayName extends React.PureComponent {
}
suffix = (
<a href={account.get('url')} target='_blank' onClick={(e) => onAccountClick(account.get('id'), e)} rel='noopener noreferrer'>
<a href={account.get('url')} target='_blank' onClick={(e) => onAccountClick(account.get('acct'), e)} rel='noopener noreferrer'>
<span className='display-name__account'>@{acct}</span>
</a>
);

View File

@@ -52,7 +52,7 @@ const Hashtag = ({ hashtag }) => (
<div className='trends__item__name'>
<Permalink
href={hashtag.get('url')}
to={`/timelines/tag/${hashtag.get('name')}`}
to={`/tags/${hashtag.get('name')}`}
>
#<span>{hashtag.get('name')}</span>
</Permalink>

View File

@@ -346,7 +346,9 @@ class Status extends ImmutablePureComponent {
return;
} else {
if (destination === undefined) {
destination = `/statuses/${
destination = `/@${
status.getIn(['reblog', 'account', 'acct'], status.getIn(['account', 'acct']))
}/${
status.getIn(['reblog', 'id'], status.get('id'))
}`;
}
@@ -362,16 +364,6 @@ class Status extends ImmutablePureComponent {
this.setState({ showMedia: !this.state.showMedia });
}
handleAccountClick = (e) => {
if (this.context.router && e.button === 0) {
const id = e.currentTarget.getAttribute('data-id');
e.preventDefault();
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${id}`, state);
}
}
handleExpandedToggle = () => {
if (this.props.status.get('spoiler_text')) {
this.setExpansion(!this.state.isExpanded);
@@ -433,13 +425,13 @@ class Status extends ImmutablePureComponent {
handleHotkeyOpen = () => {
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`, state);
this.context.router.history.push(`/@${status.getIn(['account', 'acct'])}/${status.get('id')}`, state);
}
handleHotkeyOpenProfile = () => {
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`, state);
}
handleHotkeyMoveUp = e => {

View File

@@ -148,10 +148,10 @@ class StatusActionBar extends ImmutablePureComponent {
handleOpen = () => {
let state = {...this.context.router.history.location.state};
if (state.mastodonModalKey) {
this.context.router.history.replace(`/statuses/${this.props.status.get('id')}`, { mastodonBackSteps: (state.mastodonBackSteps || 0) + 1 });
this.context.router.history.replace(`/@${this.props.status.getIn(['account', 'acct'])}/${this.props.status.get('id')}`, { mastodonBackSteps: (state.mastodonBackSteps || 0) + 1 });
} else {
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`, state);
this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}/${this.props.status.get('id')}`, state);
}
}

View File

@@ -197,7 +197,7 @@ export default class StatusContent extends React.PureComponent {
onMentionClick = (mention, e) => {
if (this.props.parseClick) {
this.props.parseClick(e, `/accounts/${mention.get('id')}`);
this.props.parseClick(e, `/@${mention.get('acct')}`);
}
}
@@ -205,7 +205,7 @@ export default class StatusContent extends React.PureComponent {
hashtag = hashtag.replace(/^#/, '');
if (this.props.parseClick) {
this.props.parseClick(e, `/timelines/tag/${hashtag}`);
this.props.parseClick(e, `/tags/${hashtag}`);
}
}
@@ -277,7 +277,7 @@ export default class StatusContent extends React.PureComponent {
const mentionLinks = status.get('mentions').map(item => (
<Permalink
to={`/accounts/${item.get('id')}`}
to={`/@${item.get('acct')}`}
href={item.get('url')}
key={item.get('id')}
className='mention'

View File

@@ -19,14 +19,14 @@ export default class StatusHeader extends React.PureComponent {
};
// Handles clicks on account name/image
handleClick = (id, e) => {
handleClick = (acct, e) => {
const { parseClick } = this.props;
parseClick(e, `/accounts/${id}`);
parseClick(e, `/@${acct}`);
}
handleAccountClick = (e) => {
const { status } = this.props;
this.handleClick(status.getIn(['account', 'id']), e);
this.handleClick(status.getIn(['account', 'acct']), e);
}
// Rendering.

View File

@@ -17,7 +17,7 @@ export default class StatusPrepend extends React.PureComponent {
handleClick = (e) => {
const { account, parseClick } = this.props;
parseClick(e, `/accounts/${account.get('id')}`);
parseClick(e, `/${account.get('acct')}`);
}
Message = () => {