From 3be4f4266db380a9095e3818e3151570f0b5378d Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 13 Jul 2023 14:32:11 +0200 Subject: [PATCH] Fix incorrect types in DisplayName --- .../glitch/components/display_name.tsx | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/javascript/flavours/glitch/components/display_name.tsx b/app/javascript/flavours/glitch/components/display_name.tsx index 7224ac3d7..76c21d00c 100644 --- a/app/javascript/flavours/glitch/components/display_name.tsx +++ b/app/javascript/flavours/glitch/components/display_name.tsx @@ -11,11 +11,12 @@ import { autoPlayGif } from '../initial_state'; import { Skeleton } from './skeleton'; interface Props { - account: Account; - others: List; - localDomain: string; + account?: Account; + others?: List; + localDomain?: string; inline?: boolean; } + export class DisplayName extends React.PureComponent { handleMouseEnter: React.ReactEventHandler = ({ currentTarget, @@ -52,7 +53,15 @@ export class DisplayName extends React.PureComponent { render() { 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) { displayName = others @@ -70,13 +79,7 @@ export class DisplayName extends React.PureComponent { if (others.size - 2 > 0) { suffix = `+${others.size - 2}`; } - } else if ((others && others.size > 0) || this.props.account) { - if (others && others.size > 0) { - account = others.first(); - } else { - account = this.props.account; - } - + } else if (account) { let acct = account.get('acct'); if (acct.indexOf('@') === -1 && localDomain) {