From 624b153a5da21c4d3bca43635ae08b1598455aa4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:57:10 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20Remove=20Reset=20Session=20for=20MLS=20c?= =?UTF-8?q?onversations=20[WPB-10426]=20=F0=9F=8D=92=20(#3304)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: boris --- .../home/conversations/ConversationScreen.kt | 2 +- .../conversations/ConversationTopAppBar.kt | 23 +- .../info/ConversationInfoViewModel.kt | 9 +- .../info/ConversationInfoViewState.kt | 14 +- .../conversations/media/FileAssetsContent.kt | 2 +- .../messages/item/MessageItemComponents.kt | 14 +- .../messages/item/MessageTypesPreview.kt | 48 ++-- .../messages/item/RegularMessageItem.kt | 220 +++++++++++------- ...SearchConversationMessagesResultsScreen.kt | 2 +- 9 files changed, 202 insertions(+), 132 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationScreen.kt index bd8363eaf6f..b61cbaaaee2 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationScreen.kt @@ -453,7 +453,7 @@ fun ConversationScreen( is ConversationDetailsData.Group -> navigator.navigate(NavigationCommand(GroupConversationDetailsScreenDestination(conversationId))) - ConversationDetailsData.None -> { /* do nothing */ + is ConversationDetailsData.None -> { /* do nothing */ } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationTopAppBar.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationTopAppBar.kt index 21c6cc03bd7..7d8aea5d205 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationTopAppBar.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationTopAppBar.kt @@ -251,7 +251,10 @@ fun PreviewConversationScreenTopAppBarLongTitle() { conversationName = UIText.DynamicString( "This is some very very very very very very very very very very long conversation title" ), - conversationDetailsData = ConversationDetailsData.Group(QualifiedID("", "")), + conversationDetailsData = ConversationDetailsData.Group( + conversationProtocol = null, + conversationId = QualifiedID("", "") + ), conversationAvatar = ConversationAvatar.OneOne(null, UserAvailabilityStatus.NONE), ), onBackButtonClick = {}, @@ -276,7 +279,10 @@ fun PreviewConversationScreenTopAppBarLongTitleWithSearch() { conversationName = UIText.DynamicString( "This is some very very very very very very very very very very long conversation title" ), - conversationDetailsData = ConversationDetailsData.Group(QualifiedID("", "")), + conversationDetailsData = ConversationDetailsData.Group( + conversationProtocol = null, + conversationId = QualifiedID("", "") + ), conversationAvatar = ConversationAvatar.OneOne(null, UserAvailabilityStatus.NONE), ), onBackButtonClick = {}, @@ -301,7 +307,10 @@ fun PreviewConversationScreenTopAppBarLongTitleWithSearchAndOngoingCall() { conversationName = UIText.DynamicString( "This is some very very very very very very very very very very long conversation title" ), - conversationDetailsData = ConversationDetailsData.Group(QualifiedID("", "")), + conversationDetailsData = ConversationDetailsData.Group( + conversationProtocol = null, + conversationId = QualifiedID("", "") + ), conversationAvatar = ConversationAvatar.OneOne(null, UserAvailabilityStatus.NONE), ), onBackButtonClick = {}, @@ -325,7 +334,7 @@ fun PreviewConversationScreenTopAppBarShortTitle() { ConversationInfoViewState( conversationId = ConversationId("value", "domain"), conversationName = UIText.DynamicString("Short title"), - conversationDetailsData = ConversationDetailsData.Group(conversationId), + conversationDetailsData = ConversationDetailsData.Group(null, conversationId), conversationAvatar = ConversationAvatar.Group(conversationId) ), onBackButtonClick = {}, @@ -349,7 +358,7 @@ fun PreviewConversationScreenTopAppBarShortTitleWithOngoingCall() { ConversationInfoViewState( conversationId = ConversationId("value", "domain"), conversationName = UIText.DynamicString("Short title"), - conversationDetailsData = ConversationDetailsData.Group(conversationId), + conversationDetailsData = ConversationDetailsData.Group(null, conversationId), conversationAvatar = ConversationAvatar.Group(conversationId) ), onBackButtonClick = {}, @@ -373,7 +382,7 @@ fun PreviewConversationScreenTopAppBarShortTitleWithVerified() { ConversationInfoViewState( conversationId = ConversationId("value", "domain"), conversationName = UIText.DynamicString("Short title"), - conversationDetailsData = ConversationDetailsData.Group(conversationId), + conversationDetailsData = ConversationDetailsData.Group(null, conversationId), conversationAvatar = ConversationAvatar.Group(conversationId), protocolInfo = Conversation.ProtocolInfo.Proteus, proteusVerificationStatus = Conversation.VerificationStatus.VERIFIED, @@ -400,7 +409,7 @@ fun PreviewConversationScreenTopAppBarShortTitleWithLegalHold() { ConversationInfoViewState( conversationId = ConversationId("value", "domain"), conversationName = UIText.DynamicString("Short title"), - conversationDetailsData = ConversationDetailsData.Group(conversationId), + conversationDetailsData = ConversationDetailsData.Group(null, conversationId), conversationAvatar = ConversationAvatar.Group(conversationId), protocolInfo = Conversation.ProtocolInfo.Proteus, legalHoldStatus = Conversation.LegalHoldStatus.ENABLED, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt index a0d6c7cc135..2ea9fa97c7d 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt @@ -133,8 +133,13 @@ class ConversationInfoViewModel @Inject constructor( private fun getConversationDetailsData(conversationDetails: ConversationDetails) = when (conversationDetails) { - is ConversationDetails.Group -> ConversationDetailsData.Group(conversationDetails.conversation.id) + is ConversationDetails.Group -> ConversationDetailsData.Group( + conversationDetails.conversation.protocol, + conversationDetails.conversation.id + ) + is ConversationDetails.OneOne -> ConversationDetailsData.OneOne( + conversationProtocol = conversationDetails.conversation.protocol, otherUserId = conversationDetails.otherUser.id, otherUserName = conversationDetails.otherUser.name, connectionState = conversationDetails.otherUser.connectionStatus, @@ -142,7 +147,7 @@ class ConversationInfoViewModel @Inject constructor( isDeleted = conversationDetails.otherUser.deleted ) - else -> ConversationDetailsData.None + else -> ConversationDetailsData.None(conversationDetails.conversation.protocol) } private fun getConversationAvatar(conversationDetails: ConversationDetails) = diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewState.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewState.kt index 4eebe93a290..155c97446c4 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewState.kt @@ -30,7 +30,7 @@ import com.wire.kalium.logic.data.user.UserId data class ConversationInfoViewState( val conversationId: QualifiedID, val conversationName: UIText = UIText.DynamicString(""), - val conversationDetailsData: ConversationDetailsData = ConversationDetailsData.None, + val conversationDetailsData: ConversationDetailsData = ConversationDetailsData.None(null), val conversationAvatar: ConversationAvatar = ConversationAvatar.None, val hasUserPermissionToEdit: Boolean = false, val conversationType: Conversation.Type = Conversation.Type.ONE_ON_ONE, @@ -44,17 +44,21 @@ data class ConversationInfoViewState( } } -sealed class ConversationDetailsData { - data object None : ConversationDetailsData() +sealed class ConversationDetailsData(open val conversationProtocol: Conversation.ProtocolInfo?) { + data class None(override val conversationProtocol: Conversation.ProtocolInfo?) : ConversationDetailsData(conversationProtocol) data class OneOne( + override val conversationProtocol: Conversation.ProtocolInfo?, val otherUserId: UserId, val otherUserName: String?, val connectionState: ConnectionState, val isBlocked: Boolean, val isDeleted: Boolean - ) : ConversationDetailsData() + ) : ConversationDetailsData(conversationProtocol) - data class Group(val conversationId: QualifiedID) : ConversationDetailsData() + data class Group( + override val conversationProtocol: Conversation.ProtocolInfo?, + val conversationId: QualifiedID + ) : ConversationDetailsData(conversationProtocol) } sealed class ConversationAvatar { diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/media/FileAssetsContent.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/media/FileAssetsContent.kt index a1bcaa24f5c..477d55c6224 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/media/FileAssetsContent.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/media/FileAssetsContent.kt @@ -119,7 +119,7 @@ private fun AssetMessagesListContent( is UIMessage.Regular -> { MessageContainerItem( message = message, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = audioMessagesState, assetStatus = assetStatuses[message.header.messageId]?.transferStatus, onLongClicked = { }, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageItemComponents.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageItemComponents.kt index ce297f266ae..80c55e80ca4 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageItemComponents.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageItemComponents.kt @@ -63,6 +63,7 @@ import com.wire.android.util.CustomTabsHelper import com.wire.android.util.EMPTY import com.wire.android.util.ui.PreviewMultipleThemes import com.wire.android.util.ui.UIText +import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.user.UserId import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentMapOf @@ -228,7 +229,8 @@ private fun SingleUserDeliveryFailure( internal fun MessageDecryptionFailure( messageHeader: MessageHeader, decryptionStatus: MessageFlowStatus.Failure.Decryption, - onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit + onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit, + conversationProtocol: Conversation.ProtocolInfo? ) { val context = LocalContext.current val learnMoreUrl = stringResource(R.string.url_decryption_failure_learn_more) @@ -251,6 +253,9 @@ internal fun MessageDecryptionFailure( text = stringResource(R.string.label_learn_more) ) VerticalSpace.x4() + + if (conversationProtocol !is Conversation.ProtocolInfo.Proteus) return@Column + Text( text = stringResource(R.string.label_message_decryption_failure_informative_message), style = LocalTextStyle.current, @@ -362,7 +367,12 @@ fun PreviewMessageSendFailureWarningWithInteractionDisabled() { @Composable fun PreviewMessageDecryptionFailure() { WireTheme { - MessageDecryptionFailure(mockHeader, MessageFlowStatus.Failure.Decryption(false)) { _, _ -> } + MessageDecryptionFailure( + mockHeader, + MessageFlowStatus.Failure.Decryption(false), + { _, _ -> }, + Conversation.ProtocolInfo.Proteus + ) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageTypesPreview.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageTypesPreview.kt index d9921f68990..bc44cf67973 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageTypesPreview.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/MessageTypesPreview.kt @@ -65,7 +65,7 @@ fun PreviewMessage() { ) ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -94,7 +94,7 @@ fun PreviewMessageWithReactions() { ), messageFooter = mockFooter ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -134,7 +134,7 @@ fun PreviewMessageWithReply() { ) ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -164,7 +164,7 @@ fun PreviewDeletedMessage() { ) ) }, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -195,7 +195,7 @@ fun PreviewFailedSendMessage() { messageFooter = mockFooter.copy(reactions = emptyMap(), ownReactions = emptySet()) ) }, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -226,7 +226,7 @@ fun PreviewFailedDecryptionMessage() { messageFooter = mockFooter.copy(reactions = emptyMap(), ownReactions = emptySet()) ) }, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -247,7 +247,7 @@ fun PreviewAssetMessageWithReactions() { WireTheme { RegularMessageItem( message = mockAssetMessage().copy(messageFooter = mockFooter), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -310,7 +310,7 @@ fun PreviewImageMessageUploaded() { WireTheme { RegularMessageItem( message = mockedImageUIMessage(messageId = "assetMessageId"), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), assetStatus = AssetTransferStatus.UPLOADED, onLongClicked = {}, @@ -332,7 +332,7 @@ fun PreviewImageMessageUploading() { WireTheme { RegularMessageItem( message = mockedImageUIMessage("assetMessageId"), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), assetStatus = AssetTransferStatus.UPLOAD_IN_PROGRESS, onLongClicked = {}, @@ -360,7 +360,7 @@ fun PreviewImageMessageFailedUpload() { expirationStatus = ExpirationStatus.NotExpirable ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), assetStatus = AssetTransferStatus.FAILED_UPLOAD, onLongClicked = {}, @@ -383,7 +383,7 @@ fun PreviewMessageWithSystemMessage() { Column { RegularMessageItem( message = mockMessageWithText, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -427,7 +427,7 @@ fun PreviewMessagesWithUnavailableQuotedMessage() { ) ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -449,7 +449,7 @@ fun PreviewAggregatedMessagesWithErrorMessage() { Column { RegularMessageItem( message = mockMessageWithText, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -470,7 +470,7 @@ fun PreviewAggregatedMessagesWithErrorMessage() { ) ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), showAuthor = false, audioMessagesState = persistentMapOf(), onLongClicked = {}, @@ -492,7 +492,7 @@ fun PreviewAggregatedMessagesWithErrorMessage() { ) ) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), showAuthor = false, audioMessagesState = persistentMapOf(), onLongClicked = {}, @@ -515,7 +515,7 @@ fun PreviewMessageWithMarkdownTextAndLinks() { WireTheme { RegularMessageItem( message = mockMessageWithMarkdownTextAndLinks, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -536,7 +536,7 @@ fun PreviewMessageWithMarkdownListAndImages() { WireTheme { RegularMessageItem( message = mockMessageWithMarkdownListAndImages, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -557,7 +557,7 @@ fun PreviewMessageWithMarkdownTablesAndBlocks() { WireTheme { RegularMessageItem( message = mockMessageWithMarkdownTablesAndBlocks, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -580,7 +580,7 @@ fun PreviewMessageWithMarkdownQuery() { RegularMessageItem( message = mockMessageWithTextLoremIpsum, searchQuery = "ed", - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -595,7 +595,7 @@ fun PreviewMessageWithMarkdownQuery() { RegularMessageItem( message = mockMessageWithMarkdownTextAndLinks, searchQuery = "code", - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -610,7 +610,7 @@ fun PreviewMessageWithMarkdownQuery() { RegularMessageItem( message = mockMessageWithMarkdownTextAndLinks, searchQuery = ".com", - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -625,7 +625,7 @@ fun PreviewMessageWithMarkdownQuery() { RegularMessageItem( message = mockMessageWithMarkdownListAndImages, searchQuery = "can", - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -640,7 +640,7 @@ fun PreviewMessageWithMarkdownQuery() { RegularMessageItem( message = mockMessageWithMarkdownTablesAndBlocks, searchQuery = "Joh", - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, @@ -666,7 +666,7 @@ fun PreviewMessageWithAccents() = WireTheme { header = mockHeader.copy(username = UIText.DynamicString(it.name), accent = it), messageContent = UIMessageContent.TextMessage(MessageBody(UIText.DynamicString("Text"))) ), - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), audioMessagesState = persistentMapOf(), onLongClicked = {}, onAssetMessageClicked = {}, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/RegularMessageItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/RegularMessageItem.kt index aa49e17a340..7614b64753b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/RegularMessageItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/messages/item/RegularMessageItem.kt @@ -118,12 +118,8 @@ import kotlin.math.min fun RegularMessageItem( message: UIMessage.Regular, conversationDetailsData: ConversationDetailsData, - searchQuery: String = "", - showAuthor: Boolean = true, audioMessagesState: PersistentMap, - assetStatus: AssetTransferStatus? = null, onLongClicked: (UIMessage.Regular) -> Unit, - swipableMessageConfiguration: SwipableMessageConfiguration = SwipableMessageConfiguration.NotSwipable, onAssetMessageClicked: (String) -> Unit, onAudioClick: (String) -> Unit, onChangeAudioPosition: (String, Int) -> Unit, @@ -131,6 +127,10 @@ fun RegularMessageItem( onOpenProfile: (String) -> Unit, onReactionClicked: (String, String) -> Unit, onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit, + searchQuery: String = "", + showAuthor: Boolean = true, + assetStatus: AssetTransferStatus? = null, + swipableMessageConfiguration: SwipableMessageConfiguration = SwipableMessageConfiguration.NotSwipable, onFailedMessageRetryClicked: (String, ConversationId) -> Unit = { _, _ -> }, onFailedMessageCancelClicked: (String) -> Unit = {}, onLinkClick: (String) -> Unit = {}, @@ -176,91 +176,50 @@ fun RegularMessageItem( } else { MessageStatusLabel(messageStatus = message.header.messageStatus) } - if (!isDeleted) { - if (!decryptionFailed) { - val currentOnAssetClicked = remember(message) { - Clickable(enabled = isAvailable, onClick = { - onAssetMessageClicked(header.messageId) - }, onLongClick = { - onLongClicked(message) - }) - } - - val currentOnImageClick = remember(message) { - Clickable(enabled = isAvailable && !isContentClickable, onClick = { - onImageMessageClicked( - message, - source == MessageSource.Self - ) - }, onLongClick = { - onLongClicked(message) - }) - } - val onLongClick: (() -> Unit)? = if (isContentClickable) { - null - } else { - remember(message) { - if (isAvailable) { - { onLongClicked(message) } - } else { - null - } - } - } - Row { - Box(modifier = Modifier.weight(1F)) { - MessageContent( - message = message, - messageContent = messageContent, - searchQuery = searchQuery, - audioMessagesState = audioMessagesState, - assetStatus = assetStatus, - onAudioClick = onAudioClick, - onChangeAudioPosition = onChangeAudioPosition, - onAssetClick = currentOnAssetClicked, - onImageClick = currentOnImageClick, - onLongClick = onLongClick, - onOpenProfile = onOpenProfile, - onLinkClick = onLinkClick, - clickable = !isContentClickable, - onReplyClickable = onReplyClickable - ) - } - if (isMyMessage && shouldDisplayMessageStatus) { - MessageStatusIndicator( - status = message.header.messageStatus.flowStatus, - isGroupConversation = conversationDetailsData is ConversationDetailsData.Group, - modifier = Modifier.padding( - top = if (message.isTextContentWithoutQuote) dimensions().spacing2x else dimensions().spacing4x, - start = dimensions().spacing8x - ) - ) - } else { - HorizontalSpace.x24() - } - } - if (shouldDisplayFooter) { - VerticalSpace.x4() - MessageFooter( - messageFooter = messageFooter, - onReactionClicked = onReactionClicked - ) - } - } else { - MessageDecryptionFailure( - messageHeader = header, - decryptionStatus = header.messageStatus.flowStatus as MessageFlowStatus.Failure.Decryption, - onResetSessionClicked = onResetSessionClicked - ) - } - if (message.sendingFailed) { - MessageSendFailureWarning( - messageStatus = header.messageStatus.flowStatus as MessageFlowStatus.Failure.Send, - isInteractionAvailable = isInteractionAvailable, - onRetryClick = remember { { onFailedMessageRetryClicked(header.messageId, message.conversationId) } }, - onCancelClick = remember { { onFailedMessageCancelClicked(header.messageId) } } + + if (isDeleted) return@Column + + if (!decryptionFailed) { + MessageContentAndStatus( + message = message, + assetStatus = assetStatus, + onAssetMessageClicked = onAssetMessageClicked, + onLongClicked = onLongClicked, + isContentClickable = isContentClickable, + onImageMessageClicked = onImageMessageClicked, + searchQuery = searchQuery, + audioMessagesState = audioMessagesState, + onAudioClick = onAudioClick, + onChangeAudioPosition = onChangeAudioPosition, + onOpenProfile = onOpenProfile, + onLinkClick = onLinkClick, + shouldDisplayMessageStatus = shouldDisplayMessageStatus, + conversationDetailsData = conversationDetailsData, + onReplyClickable = onReplyClickable + + ) + if (shouldDisplayFooter) { + VerticalSpace.x4() + MessageFooter( + messageFooter = messageFooter, + onReactionClicked = onReactionClicked ) } + } else { + MessageDecryptionFailure( + messageHeader = header, + decryptionStatus = header.messageStatus.flowStatus as MessageFlowStatus.Failure.Decryption, + onResetSessionClicked = onResetSessionClicked, + conversationProtocol = conversationDetailsData.conversationProtocol + ) + } + if (message.sendingFailed) { + MessageSendFailureWarning( + messageStatus = header.messageStatus.flowStatus as MessageFlowStatus.Failure.Send, + isInteractionAvailable = isInteractionAvailable, + onRetryClick = remember { { onFailedMessageRetryClicked(header.messageId, message.conversationId) } }, + onCancelClick = remember { { onFailedMessageCancelClicked(header.messageId) } } + ) } } } @@ -375,7 +334,9 @@ private fun SwipableToReplyBox( .fillMaxSize() .anchoredDraggable(dragState, Orientation.Horizontal, startDragImmediately = false) .offset { - val x = dragState.requireOffset().toInt() + val x = dragState + .requireOffset() + .toInt() IntOffset(x, 0) }, ) { content() } @@ -402,6 +363,87 @@ private fun ReplySwipeIcon(dragWidth: Float, density: Density, progress: Float) ) } +@Composable +private fun UIMessage.Regular.MessageContentAndStatus( + message: UIMessage.Regular, + assetStatus: AssetTransferStatus?, + onAssetMessageClicked: (String) -> Unit, + onLongClicked: (UIMessage.Regular) -> Unit, + isContentClickable: Boolean, + onImageMessageClicked: (UIMessage.Regular, Boolean) -> Unit, + searchQuery: String, + audioMessagesState: PersistentMap, + onAudioClick: (String) -> Unit, + onChangeAudioPosition: (String, Int) -> Unit, + onOpenProfile: (String) -> Unit, + onLinkClick: (String) -> Unit, + shouldDisplayMessageStatus: Boolean, + conversationDetailsData: ConversationDetailsData, + onReplyClickable: Clickable? +) { + val currentOnAssetClicked = remember(message) { + Clickable(enabled = isAvailable, onClick = { + onAssetMessageClicked(header.messageId) + }, onLongClick = { + onLongClicked(message) + }) + } + + val currentOnImageClick = remember(message) { + Clickable(enabled = isAvailable && !isContentClickable, onClick = { + onImageMessageClicked( + message, + source == MessageSource.Self + ) + }, onLongClick = { + onLongClicked(message) + }) + } + val onLongClick: (() -> Unit)? = if (isContentClickable) { + null + } else { + remember(message) { + if (isAvailable) { + { onLongClicked(message) } + } else { + null + } + } + } + Row { + Box(modifier = Modifier.weight(1F)) { + MessageContent( + message = message, + messageContent = messageContent, + searchQuery = searchQuery, + audioMessagesState = audioMessagesState, + assetStatus = assetStatus, + onAudioClick = onAudioClick, + onChangeAudioPosition = onChangeAudioPosition, + onAssetClick = currentOnAssetClicked, + onImageClick = currentOnImageClick, + onLongClick = onLongClick, + onOpenProfile = onOpenProfile, + onLinkClick = onLinkClick, + clickable = !isContentClickable, + onReplyClickable = onReplyClickable + ) + } + if (isMyMessage && shouldDisplayMessageStatus) { + MessageStatusIndicator( + status = message.header.messageStatus.flowStatus, + isGroupConversation = conversationDetailsData is ConversationDetailsData.Group, + modifier = Modifier.padding( + top = if (message.isTextContentWithoutQuote) dimensions().spacing2x else dimensions().spacing4x, + start = dimensions().spacing8x + ) + ) + } else { + HorizontalSpace.x24() + } + } +} + @Composable fun EphemeralMessageExpiredLabel(isSelfMessage: Boolean, conversationDetailsData: ConversationDetailsData) { @@ -588,10 +630,10 @@ private fun MessageContent( onImageClick: Clickable, onAudioClick: (String) -> Unit, onChangeAudioPosition: (String, Int) -> Unit, - onLongClick: (() -> Unit)? = null, onOpenProfile: (String) -> Unit, onLinkClick: (String) -> Unit, clickable: Boolean, + onLongClick: (() -> Unit)? = null, onReplyClickable: Clickable? = null ) { when (messageContent) { diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/search/messages/SearchConversationMessagesResultsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/search/messages/SearchConversationMessagesResultsScreen.kt index a6a6f6db68e..20aabb52593 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/search/messages/SearchConversationMessagesResultsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/search/messages/SearchConversationMessagesResultsScreen.kt @@ -54,7 +54,7 @@ fun SearchConversationMessagesResultsScreen( is UIMessage.Regular -> { MessageContainerItem( message = message, - conversationDetailsData = ConversationDetailsData.None, + conversationDetailsData = ConversationDetailsData.None(null), searchQuery = searchQuery, audioMessagesState = persistentMapOf(), onLongClicked = { },