Merge pull request #291 from LemmyNet/bug/fed_community_link

Fix non-local community and person links. Fixes #290
This commit is contained in:
Dessalines 2021-05-06 12:39:07 -04:00 committed by GitHub
commit fbd0001b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 12 deletions

View file

@ -36,17 +36,34 @@ export class CommunityLink extends Component<CommunityLinkProps, any> {
let apubName = `!${name_}`;
let displayName = this.props.useApubName ? apubName : title;
return (
return !this.props.realLink ? (
<Link
title={apubName}
className={`${this.props.muted ? "text-muted" : ""}`}
to={link}
>
{this.avatarAndName(displayName)}
</Link>
) : (
<a
title={apubName}
className={`${this.props.muted ? "text-muted" : ""}`}
href={link}
>
{this.avatarAndName(displayName)}
</a>
);
}
avatarAndName(displayName: string) {
let community = this.props.community;
return (
<>
{!this.props.hideAvatar && community.icon && showAvatars() && (
<PictrsImage src={community.icon} icon />
)}
<span>{displayName}</span>
</Link>
</>
);
}
}

View file

@ -44,19 +44,38 @@ export class PersonListing extends Component<PersonListingProps, any> {
return (
<>
<Link
title={apubName}
className={this.props.muted ? "text-muted" : "text-info"}
to={link}
>
{!this.props.hideAvatar && person.avatar && showAvatars() && (
<PictrsImage src={person.avatar} icon />
)}
<span>{displayName}</span>
</Link>
{!this.props.realLink ? (
<Link
title={apubName}
className={this.props.muted ? "text-muted" : "text-info"}
to={link}
>
{this.avatarAndName(displayName)}
</Link>
) : (
<a
title={apubName}
className={this.props.muted ? "text-muted" : "text-info"}
href={link}
>
{this.avatarAndName(displayName)}
</a>
)}
{isCakeDay(person.published) && <CakeDay creatorName={apubName} />}
</>
);
}
avatarAndName(displayName: string) {
let person = this.props.person;
return (
<>
{!this.props.hideAvatar && person.avatar && showAvatars() && (
<PictrsImage src={person.avatar} icon />
)}
<span>{displayName}</span>
</>
);
}
}