diff --git a/src/shared/components/community/community-link.tsx b/src/shared/components/community/community-link.tsx index 23cdc73c6..688cf73dd 100644 --- a/src/shared/components/community/community-link.tsx +++ b/src/shared/components/community/community-link.tsx @@ -20,42 +20,38 @@ export class CommunityLink extends Component { } render() { - const community = this.props.community; - let title: string, link: string; + const { community, useApubName } = this.props; const local = community.local === null ? true : community.local; - const domain = hostname(community.actor_id); + + let link: string; + let serverStr: string | undefined = undefined; + + const title = useApubName + ? community.name + : community.title ?? community.name; + if (local) { - title = community.title; link = `/c/${community.name}`; } else { - const name_ = `${community.name}@${domain}`; - title = `${community.title}@${domain}`; - link = !this.props.realLink ? `/c/${name_}` : community.actor_id; + serverStr = `@${hostname(community.actor_id)}`; + link = !this.props.realLink + ? `/c/${community.name}${serverStr}` + : community.actor_id; } + const classes = `community-link ${this.props.muted ? "text-muted" : ""}`; - const apubName = `!${community.name}@${domain}`; - const displayName = this.props.useApubName ? apubName : title; return !this.props.realLink ? ( - - {this.avatarAndName(displayName)} + + {this.avatarAndName(title, serverStr)} ) : ( - - {this.avatarAndName(displayName)} + + {this.avatarAndName(title, serverStr)} ); } - avatarAndName(displayName: string) { + avatarAndName(title: string, serverStr?: string) { const icon = this.props.community.icon; const nsfw = this.props.community.nsfw; @@ -65,7 +61,10 @@ export class CommunityLink extends Component { !this.props.community.removed && showAvatars() && icon && } - {displayName} + + {title} + {serverStr && {serverStr}} + ); } diff --git a/src/shared/components/person/person-listing.tsx b/src/shared/components/person/person-listing.tsx index 287a16ab7..ee1c09a91 100644 --- a/src/shared/components/person/person-listing.tsx +++ b/src/shared/components/person/person-listing.tsx @@ -24,64 +24,47 @@ export class PersonListing extends Component { } render() { - const person = this.props.person; + const { person, useApubName } = this.props; const local = person.local; - let apubName: string, link: string; + let link: string; + let serverStr: string | undefined = undefined; + + const name = useApubName ? person.name : person.display_name ?? person.name; if (local) { - apubName = `@${person.name}`; link = `/u/${person.name}`; } else { - const domain = hostname(person.actor_id); - apubName = `@${person.name}@${domain}`; + serverStr = `@${hostname(person.actor_id)}`; link = !this.props.realLink - ? `/u/${person.name}@${domain}` + ? `/u/${person.name}${serverStr}` : person.actor_id; } - let displayName = this.props.useApubName - ? apubName - : person.display_name ?? apubName; - - if (this.props.showApubName && !local && person.display_name) { - displayName = `${displayName} (${apubName})`; - } - + const classes = classNames( + "person-listing d-inline-flex align-items-baseline", + { + "text-muted": this.props.muted, + "text-info": !this.props.muted, + }, + ); return ( <> {!this.props.realLink ? ( - - {this.avatarAndName(displayName)} + + {this.avatarAndName(name, serverStr)} ) : ( - - {this.avatarAndName(displayName)} + + {this.avatarAndName(name, serverStr)} )} - {isCakeDay(person.published) && } + {isCakeDay(person.published) && } ); } - avatarAndName(displayName: string) { + avatarAndName(name: string, serverStr?: string) { const avatar = this.props.person.avatar; return ( <> @@ -93,7 +76,8 @@ export class PersonListing extends Component { icon /> )} - {displayName} + {name} + {serverStr && {serverStr}} ); }