Skip to content

Commit 385bb96

Browse files
Merge pull request #99 from oxinosg/master
Added PhotoMessage onError
2 parents 6398cf4 + 4609541 commit 385bb96

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ import { MessageBox } from 'react-chat-elements'
136136
| onOpen | none | function | message on open (file or photo) (message(object) is returned) |
137137
| onDownload | none | function | message on download (file or photo) (message(object) is returned) |
138138
| onLoad | none | function | message on load photo |
139+
| onPhotoError | none | function | message on error photo |
139140
| onTitleClick | none | function | message title on click event |
140141
| onForwardClick | none | function | message forward on click event |
141142
| onContextMenu | none | function | message contextmenu click event |
@@ -206,6 +207,7 @@ import { MessageList } from 'react-chat-elements'
206207
| downButtonBadge | none | boolean | message list downButton badge content |
207208
| onDownButtonClick | none | function | message list onDownButtonClick |
208209
| onContextMenu | none | function | message list item onContextMenu event, gets 3 parameters: message item, index of item, event |
210+
| onPhotoError | none | function | message list item on error photo |
209211

210212
## ChatList Component
211213

@@ -505,4 +507,4 @@ import { SpotifyMessage } from 'react-chat-elements'
505507
| view | list | string | spotify view type (list or coverart) |
506508
| data | {} | object | message data |
507509
| width | 300 | int | spotify embed width |
508-
| height | 380 | int | spotify embed height |
510+
| height | 380 | int | spotify embed height |

src/MessageBox/MessageBox.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export class MessageBox extends Component {
130130
onOpen={this.props.onOpen}
131131
onDownload={this.props.onDownload}
132132
onLoad={this.props.onLoad}
133+
onPhotoError={this.props.onPhotoError}
133134
data={this.props.data}
134135
width={this.props.width}
135136
height={this.props.height}
@@ -247,6 +248,7 @@ MessageBox.defaultProps = {
247248
onOpen: null,
248249
onDownload: null,
249250
onLoad: null,
251+
onPhotoError: null,
250252
forwarded: false,
251253
status: null,
252254
dateString: null,

src/MessageList/MessageList.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class MessageList extends Component {
5959
this.props.onDownload(item, i, e);
6060
}
6161

62+
onPhotoError(item, i, e) {
63+
if (this.props.onPhotoError instanceof Function)
64+
this.props.onPhotoError(item, i, e);
65+
}
66+
6267
onClick(item, i, e) {
6368
if (this.props.onClick instanceof Function)
6469
this.props.onClick(item, i, e);
@@ -139,6 +144,7 @@ export class MessageList extends Component {
139144
key={i}
140145
{...x}
141146
onOpen={this.props.onOpen && ((e) => this.onOpen(x, i, e))}
147+
onPhotoError={this.props.onPhotoError && ((e) => this.onPhotoError(x, i, e))}
142148
onDownload={this.props.onDownload && ((e) => this.onDownload(x, i, e))}
143149
onTitleClick={this.props.onTitleClick && ((e) => this.onTitleClick(x, i, e))}
144150
onForwardClick={this.props.onForwardClick && ((e) => this.onForwardClick(x, i, e))}
@@ -177,6 +183,7 @@ MessageList.defaultProps = {
177183
onForwardClick: null,
178184
onDownButtonClick: null,
179185
onOpen: null,
186+
onPhotoError: null,
180187
onDownload: null,
181188
dataSource: [],
182189
lockable: false,

src/PhotoMessage/PhotoMessage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class PhotoMessage extends Component {
4141
src={this.props.data.uri}
4242
alt={this.props.data.alt}
4343
onClick={this.props.onOpen}
44-
onLoad={this.props.onLoad}/>
45-
44+
onLoad={this.props.onLoad}
45+
onPhotoError={this.props.onPhotoError}/>
4646
{
4747
error &&
4848
<div className="rce-mbox-photo--img__block">
@@ -94,6 +94,7 @@ PhotoMessage.defaultProps = {
9494
onDownload: null,
9595
onOpen: null,
9696
onLoad: null,
97+
onPhotoError: null,
9798
};
9899

99100

0 commit comments

Comments
 (0)