This commit is contained in:
mgabdev
2020-03-14 13:31:29 -04:00
parent d78dd971c0
commit 65af72faae
81 changed files with 1101 additions and 662 deletions

View File

@@ -14,14 +14,21 @@ class Avatar extends ImmutablePureComponent {
}
static defaultProps = {
account: ImmutableMap(),
animate: autoPlayGif,
size: 40,
}
state = {
hovering: false,
sameImg: this.props.account.get('avatar') === this.props.account.get('avatar_static'),
sameImg: !this.props.account ? false : this.props.account.get('avatar') === this.props.account.get('avatar_static'),
}
componentDidUpdate (prevProps) {
if (prevProps.account !== this.props.account) {
this.setState({
sameImg: !this.props.account ? false : this.props.account.get('avatar') === this.props.account.get('avatar_static'),
})
}
}
handleMouseEnter = () => {
@@ -43,8 +50,8 @@ class Avatar extends ImmutablePureComponent {
className: [_s.default, _s.circle, _s.overflowHidden].join(' '),
onMouseEnter: shouldAnimate ? this.handleMouseEnter : undefined,
onMouseLeave: shouldAnimate ? this.handleMouseLeave : undefined,
src: account.get((hovering || animate) ? 'avatar' : 'avatar_static'),
alt: account.get('display_name'),
src: !account ? undefined : account.get((hovering || animate) ? 'avatar' : 'avatar_static'),
alt: !account ? undefined : account.get('display_name'),
style: {
width: `${size}px`,
height: `${size}px`,