From 058898802a377877961ff3bfa7d5209a5e275545 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 17 May 2023 23:24:27 +0200 Subject: [PATCH] Fix AvatarComposite and DisplayName referencing undefined props (#2222) --- .../glitch/components/avatar_composite.jsx | 11 +--- .../glitch/components/display_name.jsx | 59 ++++++------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/app/javascript/flavours/glitch/components/avatar_composite.jsx b/app/javascript/flavours/glitch/components/avatar_composite.jsx index 98ea9d272..1c23a8b36 100644 --- a/app/javascript/flavours/glitch/components/avatar_composite.jsx +++ b/app/javascript/flavours/glitch/components/avatar_composite.jsx @@ -9,7 +9,6 @@ export default class AvatarComposite extends React.PureComponent { accounts: ImmutablePropTypes.list.isRequired, animate: PropTypes.bool, size: PropTypes.number.isRequired, - onAccountClick: PropTypes.func.isRequired, }; static defaultProps = { @@ -80,15 +79,7 @@ export default class AvatarComposite extends React.PureComponent { }; return ( - this.props.onAccountClick(account.get('acct'), e)} - title={`@${account.get('acct')}`} - key={account.get('id')} - > -
- +
); } diff --git a/app/javascript/flavours/glitch/components/display_name.jsx b/app/javascript/flavours/glitch/components/display_name.jsx index f58a8df82..fceca5d96 100644 --- a/app/javascript/flavours/glitch/components/display_name.jsx +++ b/app/javascript/flavours/glitch/components/display_name.jsx @@ -9,12 +9,9 @@ export default class DisplayName extends React.PureComponent { static propTypes = { account: ImmutablePropTypes.map, - className: PropTypes.string, - inline: PropTypes.bool, - localDomain: PropTypes.string, others: ImmutablePropTypes.list, - handleClick: PropTypes.func, - onAccountClick: PropTypes.func, + localDomain: PropTypes.string, + inline: PropTypes.bool, }; handleMouseEnter = ({ currentTarget }) => { @@ -43,48 +40,30 @@ export default class DisplayName extends React.PureComponent { } }; - render() { - const { account, className, inline, localDomain, others, onAccountClick } = this.props; + render () { + const { others, localDomain, inline } = this.props; - const computedClass = classNames('display-name', { inline }, className); + let displayName, suffix, account; - let displayName, suffix; - let acct; + if (others && others.size > 1) { + displayName = others.take(2).map(a => ).reduce((prev, cur) => [prev, ', ', cur]); - if (account) { - acct = account.get('acct'); + 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; + } + + let acct = account.get('acct'); if (acct.indexOf('@') === -1 && localDomain) { acct = `${acct}@${localDomain}`; } - } - if (others && others.size > 0) { - displayName = others.take(2).map(a => ( - onAccountClick(a.get('acct'), e)} - title={`@${a.get('acct')}`} - rel='noopener noreferrer' - > - - - - - )).reduce((prev, cur) => [prev, ', ', cur]); - - if (others.size - 2 > 0) { - displayName.push(` +${others.size - 2}`); - } - - suffix = ( - onAccountClick(account.get('acct'), e)} rel='noopener noreferrer'> - @{acct} - - ); - } else if (account) { displayName = ; suffix = @{acct}; } else { @@ -93,7 +72,7 @@ export default class DisplayName extends React.PureComponent { } return ( - + {displayName} {inline ? ' ' : null} {suffix}