Skip to content

Commit 725c3f5

Browse files
Merge pull request #86 from Detaysoft/next
Next 10.2.0
2 parents da37c96 + c9454bc commit 725c3f5

10 files changed

Lines changed: 25 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ import { ChatList } from 'react-chat-elements'
235235
| dataSource | [] | array | chat list array |
236236
| onClick | none | function | chat list item on click (chat(object) is returned) |
237237
| onContextMenu | none | function | chat list item on context menu (chat(object) is returned) |
238+
| onAvatarError | none | function | chat list item on error avatar img |
238239

239240
## Input Component
240241

@@ -445,6 +446,7 @@ import { Avatar } from 'react-chat-elements'
445446
| size | default | string | image size. default (25px), xsmall(30px), small(35px), medium(40px), large(45px), xlarge (55px) |
446447
| type | default | string | types: default, circle, rounded(border radius 5px), flexible |
447448
| sideElement | none | component | avatar side element |
449+
| onError | none | component | avatar img onerror |
448450

449451

450452
## LocationMessage Component

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "10.1.2",
3+
"version": "10.2.0",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/Avatar/Avatar.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export class Avatar extends Component {
77
render() {
88
return (
99
<div className={classNames('rce-avatar-container', this.props.type, this.props.size, this.props.className)}>
10-
<img alt={this.props.alt} src={this.props.src} className={'rce-avatar'} />
10+
<img
11+
alt={this.props.alt}
12+
src={this.props.src}
13+
onError={this.props.onError}
14+
className={'rce-avatar'} />
1115
{this.props.sideElement}
1216
</div>
1317
);
@@ -20,6 +24,7 @@ Avatar.defaultProps = {
2024
src: '',
2125
alt: '',
2226
sideElement: null,
27+
onError: () => void(0),
2328
};
2429

2530
export default Avatar;

src/Avatar/__tests__/__snapshots__/Avatar.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`Avatar component should render without issues 1`] = `
77
<img
88
alt=""
99
className="rce-avatar"
10+
onError={[Function]}
1011
src=""
1112
/>
1213
</div>

src/ChatItem/ChatItem.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ChatItem extends Component {
2626
{this.props.statusText}
2727
</span>
2828
}
29+
onError={this.props.onAvatarError}
2930
type={classNames('circle', {'flexible': this.props.avatarFlexible})}/>
3031
</div>
3132

@@ -77,6 +78,7 @@ ChatItem.defaultProps = {
7778
statusColor: null,
7879
statusText: null,
7980
dateString: null,
81+
onAvatarError: () => void(0),
8082
}
8183

8284
export default ChatItem;

src/ChatItem/__tests__/__snapshots__/ChatItem.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exports[`ChatItem component should render without issues 1`] = `
1313
>
1414
<Avatar
1515
alt=""
16+
onError={[Function]}
1617
sideElement={null}
1718
size="large"
1819
src=""

src/ChatList/ChatList.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export class ChatList extends Component {
1818
this.props.onContextMenu(item, i, e);
1919
}
2020

21+
onAvatarError(item, i, e) {
22+
if (this.props.onAvatarError instanceof Function)
23+
this.props.onAvatarError(item, i, e);
24+
}
25+
2126
render() {
2227
return (
2328
<div
@@ -29,6 +34,7 @@ export class ChatList extends Component {
2934
id={x.id || i}
3035
key={i}
3136
{...x}
37+
onAvatarError={(e) => this.onAvatarError(x,i,e)}
3238
onContextMenu={(e) => this.onContextMenu(x,i,e)}
3339
onClick={() => this.onClick(x, i)}/>
3440
))

src/LocationMessage/LocationMessage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class LocationMessage extends Component {
4141
target={this.props.target}
4242
href={this.props.href || this.props.src || this.buildURL(MAP_URL)}
4343
className={this.className()}>
44-
<img className='rce-mbox-location-img'
44+
<img
45+
onError={this.props.onError}
46+
className='rce-mbox-location-img'
4547
src={
4648
this.props.src ||
4749
this.buildURL(STATIC_URL)
@@ -63,6 +65,7 @@ LocationMessage.defaultProps = {
6365
apiKey: '',
6466
zoom: 14,
6567
markerColor: 'red',
68+
onError: () => void(0),
6669
}
6770

6871
export default LocationMessage;

src/LocationMessage/__tests__/__snapshots__/LocationMessage.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`LocationMessage component should render without issues 1`] = `
1111
>
1212
<img
1313
className="rce-mbox-location-img"
14+
onError={[Function]}
1415
src="https://maps.googleapis.com/maps/api/staticmap?markers=color:red|undefined,undefined&zoom=14&size=270x200&scale=2&key="
1516
/>
1617
</a>

src/MessageBox/__tests__/__snapshots__/MessageBox.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports[`MessageBox component should render without issues 1`] = `
1010
>
1111
<div
1212
className="rce-mbox-body"
13+
onContextMenu={null}
1314
>
1415
<div
1516
className="rce-mbox-text"

0 commit comments

Comments
 (0)