From 86907b170c7910a3f27db4d40441b4d0b7bdb210 Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Mon, 19 Feb 2024 12:24:22 +0100 Subject: [PATCH] feat(@desktop/communities): handling bridge message replies Issue #13258 --- src/app/modules/main/activity_center/module.nim | 1 + .../main/chat_section/chat_content/messages/module.nim | 3 +++ src/app/modules/main/chat_section/chat_content/module.nim | 1 + src/app/modules/shared_models/message_item.nim | 8 ++++++++ src/app_service/service/message/dto/message.nim | 5 +++++ ui/imports/shared/views/chat/MessageView.qml | 4 ++-- 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index 625619c5a2..dfb4462a5d 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -148,6 +148,7 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: st albumMessageIds, message.albumImagesCount, message.bridgeMessage, + message.quotedMessage.bridgeMessage, )) method convertToItems*( diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 3e7f0f2b71..4b9a48194e 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -207,6 +207,7 @@ proc createMessageItemsFromMessageDtos(self: Module, messages: seq[MessageDto], if (len(message.albumId) == 0): @[] else: @[message.id], message.albumImagesCount, message.bridgeMessage, + message.quotedMessage.bridgeMessage ) self.updateLinkPreviewsContacts(item, requestFromMailserver = item.seen) @@ -286,6 +287,7 @@ proc createFetchMoreMessagesItem(self: Module): Item = albumMessageIds = @[], albumImagesCount = 0, BridgeMessage(), + BridgeMessage(), ) proc createChatIdentifierItem(self: Module): Item = @@ -352,6 +354,7 @@ proc createChatIdentifierItem(self: Module): Item = albumMessageIds = @[], albumImagesCount = 0, bridgeMessage = BridgeMessage(), + quotedBridgeMessage = BridgeMessage(), ) proc checkIfMessageLoadedAndScroll(self: Module) = diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 3bac2c1296..ba74bedc2d 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -229,6 +229,7 @@ proc buildPinnedMessageItem(self: Module, message: MessageDto, actionInitiatedBy if (len(message.albumId) == 0): @[] else: @[message.id], message.albumImagesCount, message.bridgeMessage, + message.quotedMessage.bridgeMessage, ) item.pinned = true item.pinnedBy = actionInitiatedBy diff --git a/src/app/modules/shared_models/message_item.nim b/src/app/modules/shared_models/message_item.nim index acc54e1f01..e72020dd0d 100644 --- a/src/app/modules/shared_models/message_item.nim +++ b/src/app/modules/shared_models/message_item.nim @@ -123,6 +123,7 @@ proc initItem*( albumMessageIds: seq[string], albumImagesCount: int, bridgeMessage: BridgeMessage, + quotedBridgeMessage: BridgeMessage, ): Item = result = Item() result.id = id @@ -190,6 +191,12 @@ proc initItem*( result.quotedMessageAuthorDisplayName = quotedMessageAuthorDetails.dto.userDefaultDisplayName() result.quotedMessageAuthorAvatar = quotedMessageAuthorDetails.dto.image.thumbnail + if quotedMessageContentType == ContentType.BridgeMessage: + result.quotedMessageAuthorDisplayName = quotedBridgeMessage.userName + result.quotedMessageAuthorAvatar = quotedBridgeMessage.userAvatar + result.quotedMessageText = quotedBridgeMessage.content + result.quotedMessageParsedText = quotedBridgeMessage.content + if contentType == ContentType.DiscordMessage: if result.messageText == "": @@ -269,6 +276,7 @@ proc initNewMessagesMarkerItem*(clock, timestamp: int64): Item = albumMessageIds = @[], albumImagesCount = 0, bridgeMessage = BridgeMessage(), + quotedBridgeMessage = BridgeMessage(), ) proc `$`*(self: Item): string = diff --git a/src/app_service/service/message/dto/message.nim b/src/app_service/service/message/dto/message.nim index d230bdf8a8..5df3bfecb3 100644 --- a/src/app_service/service/message/dto/message.nim +++ b/src/app_service/service/message/dto/message.nim @@ -72,6 +72,7 @@ type QuotedMessage* = object contentType*: ContentType deleted*: bool discordMessage*: DiscordMessage + bridgeMessage*: BridgeMessage albumImages*: seq[string] albumImagesCount*: int @@ -206,6 +207,10 @@ proc toQuotedMessage*(jsonObj: JsonNode): QuotedMessage = var discordMessageObj: JsonNode if(jsonObj.getProp("discordMessage", discordMessageObj)): result.discordMessage = toDiscordMessage(discordMessageObj) + + var bridgeMessageObj: JsonNode + if(jsonObj.getProp("bridgeMessage", bridgeMessageObj)): + result.bridgeMessage = toBridgeMessage(bridgeMessageObj) var quotedImagesArr: JsonNode if jsonObj.getProp("albumImages", quotedImagesArr): diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 5dcea0b53f..74c887cb5d 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -154,7 +154,7 @@ Loader { selectedUserPublicKey: isReply ? quotedMessageFrom : root.senderId, selectedUserDisplayName: isReply ? quotedMessageAuthorDetailsDisplayName : root.senderDisplayName, selectedUserIcon: isReply ? quotedMessageAuthorDetailsThumbnailImage : root.senderIcon, - isBridgedAccount: root.isBridgeMessage + isBridgedAccount: isReply ? (quotedMessageContentType === Constants.messageContentType.bridgeMessageType) : root.isBridgeMessage } Global.openMenu(profileContextMenuComponent, sender, params) @@ -825,7 +825,7 @@ Loader { height: 20 name: quotedMessageAuthorDetailsThumbnailImage assetSettings.isImage: quotedMessageAuthorDetailsThumbnailImage - showRing: (root.quotedMessageContentType !== Constants.messageContentType.discordMessageType) && !sender.isEnsVerified + showRing: (root.quotedMessageContentType !== Constants.messageContentType.discordMessageType) && !sender.isEnsVerified && (root.quotedMessageContentType !== Constants.messageContentType.bridgeMessageType) pubkey: sender.id colorId: Utils.colorIdForPubkey(sender.id) colorHash: quotedMessageAuthorDetailsColorHash