Don't display anything if TextForEvent doesn't give us any text. Fixes #253 (catapillar of doom).

This commit is contained in:
David Baker 2015-11-02 14:14:47 +00:00
parent 3b82884947
commit e869814f2d
2 changed files with 13 additions and 6 deletions

View File

@ -415,16 +415,16 @@ module.exports = {
var mxEv = new Matrix.MatrixEvent(resultList[i].result); var mxEv = new Matrix.MatrixEvent(resultList[i].result);
if (resultList[i].context.events_before[0]) { if (resultList[i].context.events_before[0]) {
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_before[0]); var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_before[0]);
if (EventTile.supportsEventType(mxEv2.getType())) { if (EventTile.haveTileForEvent(mxEv2)) {
ret.push(<li key={mxEv.getId() + "-1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>); ret.push(<li key={mxEv.getId() + "-1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
} }
} }
if (EventTile.supportsEventType(mxEv.getType())) { if (EventTile.haveTileForEvent(mxEv)) {
ret.push(<li key={mxEv.getId() + "+0"}><EventTile mxEvent={mxEv} searchTerm={this.state.searchTerm}/></li>); ret.push(<li key={mxEv.getId() + "+0"}><EventTile mxEvent={mxEv} searchTerm={this.state.searchTerm}/></li>);
} }
if (resultList[i].context.events_after[0]) { if (resultList[i].context.events_after[0]) {
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_after[0]); var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_after[0]);
if (EventTile.supportsEventType(mxEv2.getType())) { if (EventTile.haveTileForEvent(mxEv2)) {
ret.push(<li key={mxEv.getId() + "+1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>); ret.push(<li key={mxEv.getId() + "+1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
} }
} }
@ -435,7 +435,7 @@ module.exports = {
for (var i = this.state.room.timeline.length-1; i >= 0 && count < this.state.messageCap; --i) { for (var i = this.state.room.timeline.length-1; i >= 0 && count < this.state.messageCap; --i) {
var mxEv = this.state.room.timeline[i]; var mxEv = this.state.room.timeline[i];
if (!EventTile.supportsEventType(mxEv.getType())) { if (!EventTile.haveTileForEvent(mxEv)) {
continue; continue;
} }

View File

@ -24,6 +24,8 @@ var sdk = require('matrix-react-sdk')
var EventTileController = require('matrix-react-sdk/lib/controllers/molecules/EventTile') var EventTileController = require('matrix-react-sdk/lib/controllers/molecules/EventTile')
var ContextualMenu = require('../../../../ContextualMenu'); var ContextualMenu = require('../../../../ContextualMenu');
var TextForEvent = require('matrix-react-sdk/lib/TextForEvent');
var eventTileTypes = { var eventTileTypes = {
'm.room.message': 'molecules.MessageTile', 'm.room.message': 'molecules.MessageTile',
'm.room.member' : 'molecules.EventAsTextTile', 'm.room.member' : 'molecules.EventAsTextTile',
@ -39,8 +41,13 @@ module.exports = React.createClass({
mixins: [EventTileController], mixins: [EventTileController],
statics: { statics: {
supportsEventType: function(et) { haveTileForEvent: function(e) {
return eventTileTypes[et] !== undefined; if (eventTileTypes[e.getType()] == undefined) return false;
if (eventTileTypes[e.getType()] == 'molecules.EventAsTextTile') {
return TextForEvent.textForEvent(e) !== '';
} else {
return true;
}
} }
}, },