2020-04-10 20:55:57 +00:00
|
|
|
import { Component } from 'inferno';
|
|
|
|
import { Link } from 'inferno-router';
|
|
|
|
import { UserView } from '../interfaces';
|
2020-06-24 01:11:38 +00:00
|
|
|
import { pictrsAvatarThumbnail, showAvatars, hostname } from '../utils';
|
2020-04-10 20:55:57 +00:00
|
|
|
|
|
|
|
interface UserOther {
|
|
|
|
name: string;
|
2020-04-14 23:18:13 +00:00
|
|
|
id?: number; // Necessary if its federated
|
2020-04-10 20:55:57 +00:00
|
|
|
avatar?: string;
|
2020-04-14 23:18:13 +00:00
|
|
|
local?: boolean;
|
|
|
|
actor_id?: string;
|
2020-04-10 20:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface UserListingProps {
|
|
|
|
user: UserView | UserOther;
|
2020-04-30 15:45:12 +00:00
|
|
|
realLink?: boolean;
|
2020-04-10 20:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class UserListing extends Component<UserListingProps, any> {
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let user = this.props.user;
|
2020-04-14 23:18:13 +00:00
|
|
|
let local = user.local == null ? true : user.local;
|
|
|
|
let name_: string, link: string;
|
|
|
|
|
|
|
|
if (local) {
|
|
|
|
name_ = user.name;
|
|
|
|
link = `/u/${user.name}`;
|
|
|
|
} else {
|
2020-04-30 15:45:12 +00:00
|
|
|
name_ = `${user.name}@${hostname(user.actor_id)}`;
|
|
|
|
link = !this.props.realLink ? `/user/${user.id}` : user.actor_id;
|
2020-04-14 23:18:13 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 20:55:57 +00:00
|
|
|
return (
|
2020-04-14 23:18:13 +00:00
|
|
|
<Link className="text-body font-weight-bold" to={link}>
|
2020-04-10 20:55:57 +00:00
|
|
|
{user.avatar && showAvatars() && (
|
|
|
|
<img
|
|
|
|
height="32"
|
|
|
|
width="32"
|
2020-06-09 21:17:24 +00:00
|
|
|
src={pictrsAvatarThumbnail(user.avatar)}
|
2020-04-10 20:55:57 +00:00
|
|
|
class="rounded-circle mr-2"
|
|
|
|
/>
|
|
|
|
)}
|
2020-04-14 23:18:13 +00:00
|
|
|
<span>{name_}</span>
|
2020-04-10 20:55:57 +00:00
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|