From d9fecabc1ffff42566ff09df7e8c3ff69adbad76 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 27 May 2019 12:30:05 +0200 Subject: [PATCH] Fix / Edits could break cells merging Edits are not displayable --- .../timeline/factory/MessageItemFactory.kt | 4 +-- .../helper/TimelineDisplayableEvents.kt | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 6898878b..05fda074 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -105,10 +105,8 @@ class MessageItemFactory(private val colorProvider: ColorProvider, ?: //Malformed content, we should echo something on screen return DefaultItem_().text(stringProvider.getString(R.string.malformed_message)) - //TODO this should be filtered as not displayable? if (messageContent.relatesTo?.type == RelationType.REPLACE) { - //TODO blank item or ignore?? - // ignore this event + // ignore replace event, the targeted id is already edited return BlankItem_() } // val all = event.root.toContent() diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt index 53d63f58..91c39e38 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt @@ -17,6 +17,10 @@ package im.vector.riotredesign.features.home.room.detail.timeline.helper import im.vector.matrix.android.api.session.events.model.EventType +import im.vector.matrix.android.api.session.events.model.RelationType +import im.vector.matrix.android.api.session.events.model.toModel +import im.vector.matrix.android.api.session.room.model.message.MessageContent +import im.vector.matrix.android.api.session.room.model.message.MessageTextContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.core.extensions.localDateTime @@ -40,14 +44,25 @@ object TimelineDisplayableEvents { } fun TimelineEvent.isDisplayable(): Boolean { - return TimelineDisplayableEvents.DISPLAYABLE_TYPES.contains(root.type) && !root.content.isNullOrEmpty() -} - -fun List.filterDisplayableEvents(): List { - return this.filter { - it.isDisplayable() + if (!TimelineDisplayableEvents.DISPLAYABLE_TYPES.contains(root.type)) { + return false } + if (root.content.isNullOrEmpty()) { + return false + } + //Edits should be filtered out! + if (EventType.MESSAGE == root.type + && root.content.toModel()?.relatesTo?.type == RelationType.REPLACE) { + return false + } + return true } +// +//fun List.filterDisplayableEvents(): List { +// return this.filter { +// it.isDisplayable() +// } +//} fun TimelineEvent.canBeMerged(): Boolean { return root.type == EventType.STATE_ROOM_MEMBER