1 import { Component } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { UserView } from 'lemmy-js-client';
4 import { showAvatars, hostname, isCakeDay } from '../utils';
5 import { CakeDay } from './cake-day';
6 import { PictrsImage } from './pictrs-image';
8 export interface UserOther {
10 preferred_username?: string;
11 id?: number; // Necessary if its federated
18 interface UserListingProps {
19 user: UserView | UserOther;
21 useApubName?: boolean;
24 showApubName?: boolean;
27 export class UserListing extends Component<UserListingProps, any> {
28 constructor(props: any, context: any) {
29 super(props, context);
33 let user = this.props.user;
34 let local = user.local == null ? true : user.local;
35 let apubName: string, link: string;
38 apubName = `@${user.name}`;
39 link = `/u/${user.name}`;
41 apubName = `@${user.name}@${hostname(user.actor_id)}`;
42 link = !this.props.realLink ? `/user/${user.id}` : user.actor_id;
45 let displayName = this.props.useApubName
47 : user.preferred_username
48 ? user.preferred_username
51 if (this.props.showApubName && !local && user.preferred_username) {
52 displayName = `${displayName} (${apubName})`;
59 className={this.props.muted ? 'text-muted' : 'text-info'}
61 target={this.props.realLink ? '_blank' : ''}
63 {!this.props.hideAvatar && user.avatar && showAvatars() && (
64 <PictrsImage src={user.avatar} icon />
66 <span>{displayName}</span>
69 {isCakeDay(user.published) && <CakeDay creatorName={apubName} />}