From e869814f2dc2e34633a9a55342fcbb28164c16dd Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 2 Nov 2015 14:14:47 +0000 Subject: [PATCH] Don't display anything if TextForEvent doesn't give us any text. Fixes #253 (catapillar of doom). --- src/controllers/organisms/RoomView.js | 8 ++++---- src/skins/vector/views/molecules/EventTile.js | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index c0077bc0b7..f5a8d28f26 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -415,16 +415,16 @@ module.exports = { var mxEv = new Matrix.MatrixEvent(resultList[i].result); if (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(
  • ); } } - if (EventTile.supportsEventType(mxEv.getType())) { + if (EventTile.haveTileForEvent(mxEv)) { ret.push(
  • ); } if (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(
  • ); } } @@ -435,7 +435,7 @@ module.exports = { for (var i = this.state.room.timeline.length-1; i >= 0 && count < this.state.messageCap; --i) { var mxEv = this.state.room.timeline[i]; - if (!EventTile.supportsEventType(mxEv.getType())) { + if (!EventTile.haveTileForEvent(mxEv)) { continue; } diff --git a/src/skins/vector/views/molecules/EventTile.js b/src/skins/vector/views/molecules/EventTile.js index 6c2f948ca5..c5cb81951b 100644 --- a/src/skins/vector/views/molecules/EventTile.js +++ b/src/skins/vector/views/molecules/EventTile.js @@ -24,6 +24,8 @@ var sdk = require('matrix-react-sdk') var EventTileController = require('matrix-react-sdk/lib/controllers/molecules/EventTile') var ContextualMenu = require('../../../../ContextualMenu'); +var TextForEvent = require('matrix-react-sdk/lib/TextForEvent'); + var eventTileTypes = { 'm.room.message': 'molecules.MessageTile', 'm.room.member' : 'molecules.EventAsTextTile', @@ -39,8 +41,13 @@ module.exports = React.createClass({ mixins: [EventTileController], statics: { - supportsEventType: function(et) { - return eventTileTypes[et] !== undefined; + haveTileForEvent: function(e) { + if (eventTileTypes[e.getType()] == undefined) return false; + if (eventTileTypes[e.getType()] == 'molecules.EventAsTextTile') { + return TextForEvent.textForEvent(e) !== ''; + } else { + return true; + } } },