fix(chat): Display text from image message

Fixes: #9564
This commit is contained in:
Boris Melnik 2023-02-27 23:24:03 +03:00
parent e6226ab564
commit 18e5fc915c
3 changed files with 30 additions and 7 deletions

View File

@ -199,12 +199,14 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
pinnedMessages: seq[PinnedMessageDto]) = pinnedMessages: seq[PinnedMessageDto]) =
var viewItems: seq[Item] var viewItems: seq[Item]
var prevMessage = Item()
if(messages.len > 0): if(messages.len > 0):
for message in messages: for message in messages:
# https://github.com/status-im/status-desktop/issues/7632 will introduce deleteFroMe feature. # https://github.com/status-im/status-desktop/issues/7632 will introduce deleteFroMe feature.
# Now we just skip deleted messages # Now we just skip deleted messages
if message.deleted or message.deletedForMe: if message.deleted or message.deletedForMe:
continue continue
let chatDetails = self.controller.getChatDetails() let chatDetails = self.controller.getChatDetails()
let sender = self.controller.getContactDetails(message.`from`) let sender = self.controller.getContactDetails(message.`from`)
@ -219,7 +221,12 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
if chatDetails.communityId != "": if chatDetails.communityId != "":
communityChats = self.controller.getCommunityById(chatDetails.communityId).chats communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats) var renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
# Skipping duplication text from image messages whith same text
if (prevMessage.contentType.ContentType == ContentType.Image and prevMessage.messageText == renderedMessageText):
renderedMessageText = ""
var transactionContract = message.transactionParameters.contract var transactionContract = message.transactionParameters.contract
var transactionValue = message.transactionParameters.value var transactionValue = message.transactionParameters.value
var isCurrentUser = sender.isCurrentUser var isCurrentUser = sender.isCurrentUser
@ -275,6 +282,8 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
quotedMessageAuthorDetails quotedMessageAuthorDetails
) )
prevMessage = item
for r in reactions: for r in reactions:
if(r.messageId == message.id): if(r.messageId == message.id):
var emojiIdAsEnum: EmojiId var emojiIdAsEnum: EmojiId

View File

@ -108,8 +108,8 @@ proc initItem*(
result.senderColorHash = senderColorHash result.senderColorHash = senderColorHash
result.seen = seen result.seen = seen
result.outgoingStatus = outgoingStatus result.outgoingStatus = outgoingStatus
result.messageText = if contentType == ContentType.Image : "" else: text result.messageText = text
result.unparsedText = if contentType == ContentType.Image : "" else: unparsedText result.unparsedText = unparsedText
result.messageImage = image result.messageImage = image
result.messageContainsMentions = messageContainsMentions result.messageContainsMentions = messageContainsMentions
result.timestamp = timestamp result.timestamp = timestamp

View File

@ -274,12 +274,26 @@ Control {
Loader { Loader {
active: root.messageDetails.contentType === StatusMessage.ContentType.Image && !editMode active: root.messageDetails.contentType === StatusMessage.ContentType.Image && !editMode
visible: active visible: active
sourceComponent: StatusImageMessage { sourceComponent: Column {
spacing: 8
Loader {
active: root.messageDetails.messageText !== ""
visible: active
sourceComponent: StatusTextMessage {
messageDetails: root.messageDetails
onLinkActivated: {
root.linkActivated(link);
}
}
}
StatusImageMessage {
source: root.messageDetails.messageContent source: root.messageDetails.messageContent
onClicked: root.imageClicked(image, mouse, imageSource) onClicked: root.imageClicked(image, mouse, imageSource)
shapeType: root.messageDetails.amISender ? StatusImageMessage.ShapeType.RIGHT_ROUNDED : StatusImageMessage.ShapeType.LEFT_ROUNDED shapeType: root.messageDetails.amISender ? StatusImageMessage.ShapeType.RIGHT_ROUNDED : StatusImageMessage.ShapeType.LEFT_ROUNDED
} }
} }
}
Loader { Loader {
active: root.messageAttachments && !editMode active: root.messageAttachments && !editMode
visible: active visible: active