Skip to content

Commit bab6f58

Browse files
committed
Remove handleError from Avatar
1 parent 124a3e8 commit bab6f58

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/shared/components/Avatar/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020

2121
import PT from 'prop-types';
2222
import React from 'react';
23-
import _ from 'lodash';
2423
import { themr } from 'react-css-themr';
2524
import DefaultAvatar from '../../../assets/images/ico-user-default.svg';
2625
import defaultStyle from './style.scss';
2726

28-
function Avatar({ theme, url, handleError }) {
27+
function Avatar({ theme, url }) {
2928
return url
30-
? <img alt="Avatar" src={url} className={theme.avatar} onError={handleError} />
29+
? <img alt="Avatar" src={url} className={theme.avatar} />
3130
: <DefaultAvatar className={theme.avatar} />;
3231
}
3332

@@ -37,15 +36,13 @@ Avatar.defaultProps = {
3736
avatar: '',
3837
},
3938
url: null,
40-
handleError: _.noop,
4139
};
4240

4341
Avatar.propTypes = {
4442
theme: PT.shape({
4543
avatar: PT.string.isRequired,
4644
}),
4745
url: PT.string,
48-
handleError: PT.func,
4946
};
5047

5148
export default themr('Avatar', defaultStyle)(Avatar);

src/shared/components/challenge-listing/Tooltips/UserAvatarTooltip/index.jsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PT from 'prop-types';
1313
import Tooltip from 'components/Tooltip';
1414
import Avatar from 'components/Avatar';
1515
import styles from './style.scss';
16+
import config from 'utils/config';
1617

1718
/**
1819
* Renders the tooltip's content.
@@ -31,10 +32,7 @@ function Tip(props) {
3132
</span>
3233
)); */
3334
const { photoLink } = props.user;
34-
let src = null;
35-
if (photoLink) {
36-
src = photoLink.startsWith('https') ? photoLink : `${props.MAIN_URL}/${photoLink}`;
37-
}
35+
const src = photoLink.startsWith('https') ? photoLink : `${config.URL.BASE}/${photoLink}`;
3836

3937
return (
4038
<div styleName="user-avatar-tooltip">
@@ -43,7 +41,6 @@ function Tip(props) {
4341
avatar: styles.avatar,
4442
}}
4543
url={src}
46-
handleError={props.handleError}
4744
/>
4845
<div styleName="handle">{props.user.handle}</div>
4946
{/* Below block is commented out as it's not possible to get this information
@@ -62,8 +59,6 @@ function Tip(props) {
6259
}
6360

6461
Tip.propTypes = {
65-
handleError: PT.func.isRequired,
66-
MAIN_URL: PT.string,
6762
user: PT.shape({
6863
country: PT.string,
6964
handle: PT.string,
@@ -73,10 +68,6 @@ Tip.propTypes = {
7368
}).isRequired,
7469
};
7570

76-
Tip.defaultProps = {
77-
MAIN_URL: process.env.MAIN_URL,
78-
};
79-
8071
/**
8172
* Renders the tooltip.
8273
*/
@@ -86,16 +77,10 @@ class UserAvatarTooltip extends Component {
8677
this.state = {
8778
user: props.user,
8879
};
89-
this.handleError = this.handleError.bind(this);
90-
}
91-
handleError() {
92-
const user = this.state.user;
93-
user.photoLink = null;
94-
this.setState({ user });
9580
}
9681

9782
render() {
98-
const tip = <Tip user={this.state.user} handleError={this.handleError} />;
83+
const tip = <Tip user={this.state.user} />;
9984
return (
10085
<Tooltip content={tip}>
10186
<div>{this.props.children}</div>

0 commit comments

Comments
 (0)