From c2d3536dd8de2a945664b532e6c0de2fabbee54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Zag=C3=B3rski?= Date: Tue, 22 Oct 2024 10:27:07 +0200 Subject: [PATCH] fix: Failed image message are not visible on chat #WPB-11035 (#3516) --- .../com/wire/android/mapper/RegularMessageContentMapper.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt index 5c1a62d1e98..6336f558bb4 100644 --- a/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt +++ b/app/src/main/kotlin/com/wire/android/mapper/RegularMessageContentMapper.kt @@ -38,10 +38,10 @@ import com.wire.kalium.logic.data.message.DeliveryStatus import com.wire.kalium.logic.data.message.Message import com.wire.kalium.logic.data.message.MessageContent import com.wire.kalium.logic.data.message.MessageContent.Asset +import com.wire.kalium.logic.data.message.hasValidData import com.wire.kalium.logic.data.user.AssetId import com.wire.kalium.logic.data.user.SelfUser import com.wire.kalium.logic.data.user.User -import com.wire.kalium.logic.sync.receiver.conversation.message.hasValidRemoteData import com.wire.kalium.logic.util.isGreaterThan import kotlinx.collections.immutable.toPersistentList import kotlinx.collections.immutable.toPersistentMap @@ -239,7 +239,8 @@ class RegularMessageMapper @Inject constructor( with(assetMessageContentMetadata.assetMessageContent) { when { // If some of image data are still missing, we mark it as incomplete which won't be shown until we get missing data - assetMessageContentMetadata.isIncompleteImage() -> { + // But we also check if isnt our own message, if its our own, most likely the there was an error sending the image. + assetMessageContentMetadata.isIncompleteImage() && sender !is SelfUser -> { UIMessageContent.IncompleteAssetMessage } @@ -306,7 +307,7 @@ class AssetMessageContentMetadata(val assetMessageContent: AssetContent) { // Sometimes client receives two events for the same asset, first one with only part of the data ("preview" type from web), // so such asset shouldn't be shown until all the required data is received. - fun isIncompleteImage(): Boolean = isDisplayableImage() && !assetMessageContent.hasValidRemoteData() + fun isIncompleteImage(): Boolean = isDisplayableImage() && !assetMessageContent.remoteData.hasValidData() } private fun String?.orUnknownName(): UIText = when {