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]) =
var viewItems: seq[Item]
var prevMessage = Item()
if(messages.len > 0):
for message in messages:
# https://github.com/status-im/status-desktop/issues/7632 will introduce deleteFroMe feature.
# Now we just skip deleted messages
if message.deleted or message.deletedForMe:
continue
let chatDetails = self.controller.getChatDetails()
let sender = self.controller.getContactDetails(message.`from`)
@ -219,7 +221,12 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
if chatDetails.communityId != "":
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 transactionValue = message.transactionParameters.value
var isCurrentUser = sender.isCurrentUser
@ -275,6 +282,8 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
quotedMessageAuthorDetails
)
prevMessage = item
for r in reactions:
if(r.messageId == message.id):
var emojiIdAsEnum: EmojiId

View File

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

View File

@ -274,10 +274,24 @@ Control {
Loader {
active: root.messageDetails.contentType === StatusMessage.ContentType.Image && !editMode
visible: active
sourceComponent: StatusImageMessage {
source: root.messageDetails.messageContent
onClicked: root.imageClicked(image, mouse, imageSource)
shapeType: root.messageDetails.amISender ? StatusImageMessage.ShapeType.RIGHT_ROUNDED : StatusImageMessage.ShapeType.LEFT_ROUNDED
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
onClicked: root.imageClicked(image, mouse, imageSource)
shapeType: root.messageDetails.amISender ? StatusImageMessage.ShapeType.RIGHT_ROUNDED : StatusImageMessage.ShapeType.LEFT_ROUNDED
}
}
}
Loader {