From b3599aac233dd28e5a5fd82d69e79a052843eb95 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 21 Apr 2022 10:43:41 +0200 Subject: [PATCH] Put redactions into bubbles, no matter what the original type was Change-Id: I6b7e424a29b1f8eb54862fc0a58102dcfaa8642c --- .../timeline/style/TimelineMessageLayoutFactory.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt index 4ebba047e0..944540e88e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt @@ -106,7 +106,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess val messageContent = event.getLastMessageContent() val isBubble = event.shouldBuildBubbleLayout() val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START - val pseudoBubble = messageContent.isPseudoBubble() + val pseudoBubble = messageContent.isPseudoBubble(event) val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps() return TimelineMessageLayout.ScBubble( showAvatar = showInformation, @@ -153,7 +153,7 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess addTopMargin = isFirstFromThisSender && isSentByMe, isIncoming = !isSentByMe, cornersRadius = cornersRadius, - isPseudoBubble = messageContent.isPseudoBubble(), + isPseudoBubble = messageContent.isPseudoBubble(event), timestampAsOverlay = messageContent.timestampAsOverlay() ) } else { @@ -194,8 +194,9 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess } } - private fun MessageContent?.isPseudoBubble(): Boolean { + private fun MessageContent?.isPseudoBubble(event: TimelineEvent): Boolean { if (this == null) return false + if (event.root.isRedacted()) return false if (msgType == MessageType.MSGTYPE_LOCATION) return vectorPreferences.labsRenderLocationsInTimeline() return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT } @@ -212,6 +213,10 @@ class TimelineMessageLayoutFactory @Inject constructor(private val session: Sess } private fun TimelineEvent.shouldBuildBubbleLayout(): Boolean { + if (root.isRedacted()) { + // Redacted messages always go into bubbles + return true + } val type = root.getClearType() if (type in EVENT_TYPES_WITH_BUBBLE_LAYOUT) { val messageContent = getLastMessageContent()