In threads, reply fallback shouldn't cause stickers to render as bubble

Change-Id: I9539c77520e2d1563c3e782d649c2868e08ad81a
This commit is contained in:
SpiritCroc 2023-04-01 16:05:38 +02:00
parent 5f787db4f1
commit f4e9559eca
3 changed files with 13 additions and 4 deletions

View file

@ -27,6 +27,7 @@ import org.matrix.android.sdk.api.session.events.model.isEdition
import org.matrix.android.sdk.api.session.events.model.isLiveLocation
import org.matrix.android.sdk.api.session.events.model.isPoll
import org.matrix.android.sdk.api.session.events.model.isReply
import org.matrix.android.sdk.api.session.events.model.isReplyRenderedInThread
import org.matrix.android.sdk.api.session.events.model.isSticker
import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.events.model.toModel
@ -206,6 +207,10 @@ fun TimelineEvent.isReply(): Boolean {
return root.isReply()
}
fun TimelineEvent.isReplyRenderedInThread(): Boolean {
return root.isReplyRenderedInThread()
}
fun TimelineEvent.isEdition(): Boolean {
return root.isEdition()
}

View file

@ -50,6 +50,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited
import org.matrix.android.sdk.api.session.room.timeline.isReply
import org.matrix.android.sdk.api.session.room.timeline.isReplyRenderedInThread
import timber.log.Timber
import javax.inject.Inject
@ -160,7 +161,7 @@ class MessageInformationDataFactory @Inject constructor(
senderPowerLevel = senderPowerLevel,
isDirect = isEffectivelyDirect,
isPublic = roomSummary?.isPublic ?: false,
isReply = event.isReply(),
isReply = if (params.isFromThreadTimeline()) event.isReplyRenderedInThread() else event.isReply(),
dmChatPartnerId = dmOtherMemberId,
isFirstFromThisSender = isFirstFromThisSender,
isLastFromThisSender = isLastFromThisSender,

View file

@ -26,6 +26,7 @@ import im.vector.app.features.home.room.detail.timeline.factory.TimelineItemFact
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.themes.BubbleThemeUtils
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
@ -39,6 +40,7 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
import org.matrix.android.sdk.api.session.room.timeline.isEdition
import org.matrix.android.sdk.api.session.room.timeline.isReply
import org.matrix.android.sdk.api.session.room.timeline.isReplyRenderedInThread
import org.matrix.android.sdk.api.session.room.timeline.isRootThread
import javax.inject.Inject
@ -129,7 +131,7 @@ class TimelineMessageLayoutFactory @Inject constructor(
val messageContent = event.getLastMessageContent()
val isBubble = event.shouldBuildBubbleLayout()
val singleSidedLayout = bubbleThemeUtils.getBubbleStyle() == BubbleThemeUtils.BUBBLE_STYLE_START
val pseudoBubble = messageContent.isPseudoBubble(event)
val pseudoBubble = messageContent.isPseudoBubble(event, params = params)
val showTimestamp = showInformation || !singleSidedLayout || vectorPreferences.alwaysShowTimeStamps()
return TimelineMessageLayout.ScBubble(
showAvatar = showInformation,
@ -217,10 +219,11 @@ class TimelineMessageLayoutFactory @Inject constructor(
}
}
private fun MessageContent?.isPseudoBubble(event: TimelineEvent, ignoreReply: Boolean = false): Boolean {
private fun MessageContent?.isPseudoBubble(event: TimelineEvent, ignoreReply: Boolean = false, params: TimelineItemFactoryParams? = null): Boolean {
if (this == null) return false
if (event.root.isRedacted()) return false
if (!ignoreReply && event.isReply()) return false
val isReply = if (params?.isFromThreadTimeline().orFalse()) event.isReplyRenderedInThread() else event.isReply()
if (!ignoreReply && isReply) return false
if (this is MessageWithAttachmentContent && !getCaption().isNullOrBlank()) return false
return this.msgType in MSG_TYPES_WITH_PSEUDO_BUBBLE_LAYOUT
}