feat(@desktop/communities): handling bridge message replies

Issue #13258
This commit is contained in:
Michal Iskierko 2024-02-19 12:24:22 +01:00 committed by Michał Iskierko
parent f31d6131c3
commit 86907b170c
6 changed files with 20 additions and 2 deletions

View File

@ -148,6 +148,7 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: st
albumMessageIds,
message.albumImagesCount,
message.bridgeMessage,
message.quotedMessage.bridgeMessage,
))
method convertToItems*(

View File

@ -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) =

View File

@ -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

View File

@ -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 =

View File

@ -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):

View File

@ -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