add the concept of eventTileOps for managing widget visibility based on vdh's PR feedback

This commit is contained in:
Matthew Hodgson 2016-04-08 21:42:29 +01:00
parent 23d6edbf63
commit 6c372d37f7
3 changed files with 26 additions and 21 deletions

View file

@ -42,11 +42,14 @@ module.exports = React.createClass({
onWidgetLoad: React.PropTypes.func,
},
getEventTileOps: function() {
return this.refs.body ? this.refs.body.getEventTileOps() : null;
},
render: function() {
var UnknownMessageTile = sdk.getComponent('messages.UnknownBody');
var UnknownBody = sdk.getComponent('messages.UnknownBody');
var tileTypes = {
var bodyTypes = {
'm.text': sdk.getComponent('messages.TextualBody'),
'm.notice': sdk.getComponent('messages.TextualBody'),
'm.emote': sdk.getComponent('messages.TextualBody'),
@ -57,12 +60,12 @@ module.exports = React.createClass({
var content = this.props.mxEvent.getContent();
var msgtype = content.msgtype;
var TileType = UnknownMessageTile;
if (msgtype && tileTypes[msgtype]) {
TileType = tileTypes[msgtype];
var BodyType = UnknownBody;
if (msgtype && bodyTypes[msgtype]) {
BodyType = bodyTypes[msgtype];
}
return <TileType mxEvent={this.props.mxEvent} highlights={this.props.highlights}
return <BodyType ref="body" mxEvent={this.props.mxEvent} highlights={this.props.highlights}
highlightLink={this.props.highlightLink}
onWidgetLoad={this.props.onWidgetLoad} />;
},