Fix incorrect types in DisplayName

lolsob-rspec
Claire 2023-07-13 14:32:11 +02:00
parent 3c714ea3d2
commit 90a0f97140
1 changed files with 14 additions and 11 deletions

View File

@ -11,11 +11,12 @@ import { autoPlayGif } from '../initial_state';
import { Skeleton } from './skeleton'; import { Skeleton } from './skeleton';
interface Props { interface Props {
account: Account; account?: Account;
others: List<Account>; others?: List<Account>;
localDomain: string; localDomain?: string;
inline?: boolean; inline?: boolean;
} }
export class DisplayName extends React.PureComponent<Props> { export class DisplayName extends React.PureComponent<Props> {
handleMouseEnter: React.ReactEventHandler<HTMLSpanElement> = ({ handleMouseEnter: React.ReactEventHandler<HTMLSpanElement> = ({
currentTarget, currentTarget,
@ -52,7 +53,15 @@ export class DisplayName extends React.PureComponent<Props> {
render() { render() {
const { others, localDomain, inline } = this.props; const { others, localDomain, inline } = this.props;
let displayName: React.ReactNode, suffix: React.ReactNode, account: Account; let displayName: React.ReactNode,
suffix: React.ReactNode,
account: Account | undefined;
if (others && others.size > 0) {
account = others.first();
} else if (this.props.account) {
account = this.props.account;
}
if (others && others.size > 1) { if (others && others.size > 1) {
displayName = others displayName = others
@ -70,13 +79,7 @@ export class DisplayName extends React.PureComponent<Props> {
if (others.size - 2 > 0) { if (others.size - 2 > 0) {
suffix = `+${others.size - 2}`; suffix = `+${others.size - 2}`;
} }
} else if ((others && others.size > 0) || this.props.account) { } else if (account) {
if (others && others.size > 0) {
account = others.first();
} else {
account = this.props.account;
}
let acct = account.get('acct'); let acct = account.get('acct');
if (acct.indexOf('@') === -1 && localDomain) { if (acct.indexOf('@') === -1 && localDomain) {