From 008572afe12793663a05112cedadb1aad3d698f8 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 6 Apr 2018 16:42:59 +0100 Subject: [PATCH 1/2] Revert "Handle non-m.room.message event types." This reverts commit f8d7ab10fab9c742f2351477e698d5f6b0e6a5d1. --- src/components/structures/MessagePanel.js | 7 +------ src/components/views/rooms/EventTile.js | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 773c9710dd..6a8c2e9c2e 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -450,12 +450,7 @@ module.exports = React.createClass({ if (prevEvent !== null && prevEvent.sender && mxEv.sender && mxEv.sender.userId === prevEvent.sender.userId - // The preferred way of checking for 'continuation messages' is by - // checking whether subsiquent messages from the same user have a - // message body. This is because all messages intended to be displayed - // should have a 'body' whereas some (non-m.room) messages (such as - // m.sticker) may not have a message 'type'. - && Boolean(mxEv.getContent().body) == Boolean(prevEvent.getContent().body)) { + && mxEv.getType() == prevEvent.getType()) { continuation = true; } diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 5e453e66d0..367e31e3b4 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -471,8 +471,7 @@ module.exports = withMatrixClient(React.createClass({ const eventType = this.props.mxEvent.getType(); // Info messages are basically information about commands processed on a room - // For now assume that anything that doesn't have a content body is an isInfoMessage - const isInfoMessage = !content.body; // Boolean comparison of non-boolean content body + const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.room.sticker'); const EventTileType = sdk.getComponent(getHandlerTile(this.props.mxEvent)); // This shouldn't happen: the caller should check we support this type From 01dd494f508ae8c9e69d7007cfc3259a961b48a4 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 6 Apr 2018 17:47:44 +0100 Subject: [PATCH 2/2] Make stickers/messages continuations of each other --- src/components/structures/MessagePanel.js | 10 +++++++++- src/components/views/rooms/EventTile.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 6a8c2e9c2e..50bdb37734 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -447,10 +447,18 @@ module.exports = React.createClass({ // is this a continuation of the previous message? let continuation = false; + // Some events should appear as continuations from previous events of + // different types. + const continuedTypes = ['m.sticker', 'm.room.message']; + const eventTypeContinues = + prevEvent !== null && + continuedTypes.includes(mxEv.getType()) && + continuedTypes.includes(prevEvent.getType()); + if (prevEvent !== null && prevEvent.sender && mxEv.sender && mxEv.sender.userId === prevEvent.sender.userId - && mxEv.getType() == prevEvent.getType()) { + && (mxEv.getType() == prevEvent.getType() || eventTypeContinues)) { continuation = true; } diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 367e31e3b4..ed7851bf2d 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -471,7 +471,7 @@ module.exports = withMatrixClient(React.createClass({ const eventType = this.props.mxEvent.getType(); // Info messages are basically information about commands processed on a room - const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.room.sticker'); + const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.sticker'); const EventTileType = sdk.getComponent(getHandlerTile(this.props.mxEvent)); // This shouldn't happen: the caller should check we support this type