Skip to content

Commit d107151

Browse files
committed
rename size prop as fileSize, add comments, and honour explicit properties rather than mxEvent fields
1 parent 48abc75 commit d107151

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

‎src/components/views/elements/ImageView.js‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@ module.exports = React.createClass({
2727
displayName: 'ImageView',
2828

2929
propTypes: {
30+
src: React.PropTypes.string.isRequired, // the source of the image being displayed
31+
name: React.PropTypes.string, // the main title ('name') for the image
32+
link: React.PropTypes.string, // the link (if any) applied to the name of the image
33+
width: React.PropTypes.number, // width of the image src in pixels
34+
height: React.PropTypes.number, // height of the image src in pixels
35+
fileSize: React.PropTypes.number, // size of the image src in bytes
36+
onFinished: React.PropTypes.func.isRequired, // callback when the lightbox is dismissed
37+
38+
// the event (if any) that the Image is displaying. Used for event-specific stuff like
39+
// redactions, senders, timestamps etc. Other descriptors are taken from the explicit
40+
// properties above, which let us use lightboxes to display images which aren't associated
41+
// with events.
3042
mxEvent: React.PropTypes.object,
31-
src: React.PropTypes.string.isRequired,
32-
link: React.PropTypes.string,
33-
width: React.PropTypes.number,
34-
height: React.PropTypes.number,
35-
size: React.PropTypes.number,
36-
onFinished: React.PropTypes.func.isRequired,
37-
name: React.PropTypes.string
3843
},
3944

4045
// XXX: keyboard shortcuts for managing dialogs should be done by the modal
@@ -73,20 +78,10 @@ module.exports = React.createClass({
7378
},
7479

7580
getName: function () {
76-
var name;
77-
78-
if(this.props.name) {
79-
name = this.props.name;
80-
} else if(this.props.mxEvent) {
81-
name = this.props.mxEvent.getContent().body;
82-
} else {
83-
name = null;
84-
}
85-
81+
var name = this.props.name;
8682
if (name && this.props.link) {
8783
name = <a href={ this.props.link } target="_blank">{ name }</a>;
8884
}
89-
9085
return name;
9186
},
9287

@@ -131,8 +126,8 @@ module.exports = React.createClass({
131126
}
132127

133128
var size;
134-
if (this.props.size) {
135-
size = filesize(this.props.size);
129+
if (this.props.fileSize) {
130+
size = filesize(this.props.fileSize);
136131
}
137132

138133
var size_res;

0 commit comments

Comments
 (0)