fix(edit): fix message edits loses the album of images (#16827)

Fixes #16741

The problem was that we replaced the ContentType from Image to Text, so on restart, it doesn't understand it had images anymore.

Fixed in status-go by reusing the ContentType of the original message.

This makes it so that we don't need to pass the ContentType from Nim anymore, so I removed that param from the code.
This commit is contained in:
Jonathan Rainville 2024-12-04 11:11:56 -05:00 committed by GitHub
parent 59cde995d1
commit 387eab4fcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 14 additions and 15 deletions

View File

@ -292,8 +292,8 @@ proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], commun
proc deleteMessage*(self: Controller, messageId: string) =
self.messageService.deleteMessage(messageId)
proc editMessage*(self: Controller, messageId: string, contentType: int, updatedMsg: string) =
self.messageService.editMessage(messageId, contentType, updatedMsg)
proc editMessage*(self: Controller, messageId: string, updatedMsg: string) =
self.messageService.editMessage(messageId, updatedMsg)
proc getSearchedMessageId*(self: Controller): string =
return self.searchedMessageId

View File

@ -129,7 +129,7 @@ method onMessageRemoved*(self: AccessInterface, messageId, removedBy: string) {.
method onMessagesDeleted*(self: AccessInterface, messageIds: seq[string]) {.base.} =
raise newException(ValueError, "No implementation available")
method editMessage*(self: AccessInterface, messageId: string, contentType: int, updatedMsg: string) {.base.} =
method editMessage*(self: AccessInterface, messageId: string, updatedMsg: string) {.base.} =
raise newException(ValueError, "No implementation available")
method onHistoryCleared*(self: AccessInterface) {.base.} =

View File

@ -601,8 +601,8 @@ method onMessagesDeleted*(self: Module, messageIds: seq[string]) =
for messageId in messageIds:
self.view.model().removeItem(messageId)
method editMessage*(self: Module, messageId: string, contentType: int, updatedMsg: string) =
self.controller.editMessage(messageId, contentType, updatedMsg)
method editMessage*(self: Module, messageId: string, updatedMsg: string) =
self.controller.editMessage(messageId, updatedMsg)
method onMessageEdited*(self: Module, message: MessageDto) =
let itemBeforeChange = self.view.model().getItemWithMessageId(message.id)

View File

@ -120,8 +120,8 @@ QtObject:
proc setEditModeOff*(self: View, messageId: string) {.slot.} =
self.model.setEditModeOff(messageId)
proc editMessage*(self: View, messageId: string, contentType: int, updatedMsg: string) {.slot.} =
self.delegate.editMessage(messageId, contentType, updatedMsg)
proc editMessage*(self: View, messageId: string, updatedMsg: string) {.slot.} =
self.delegate.editMessage(messageId, updatedMsg)
proc switchToMessage(self: View, messageIndex: int) {.signal.}
proc emitSwitchToMessageSignal*(self: View, messageIndex: int) =

View File

@ -1157,12 +1157,12 @@ proc bulkReplacePubKeysWithDisplayNames(self: Service, messages: var seq[Message
for i in 0..<messages.len:
messages[i].text = message_common.replacePubKeysWithDisplayNames(allKnownContacts, messages[i].text)
proc editMessage*(self: Service, messageId: string, contentType: int, msg: string) =
proc editMessage*(self: Service, messageId: string, msg: string) =
try:
let allKnownContacts = self.contactService.getContactsByGroup(ContactsGroup.AllKnownContacts)
let processedMsg = message_common.replaceMentionsWithPubKeys(allKnownContacts, msg)
let response = status_go.editMessage(messageId, contentType, processedMsg)
let response = status_go.editMessage(messageId, processedMsg)
var messagesArr: JsonNode
var messages: seq[MessageDto]

View File

@ -66,8 +66,8 @@ proc markCertainMessagesFromChatWithIdAsRead*(chatId: string, messageIds: seq[st
proc deleteMessageAndSend*(messageID: string): RpcResponse[JsonNode] =
result = callPrivateRPC("deleteMessageAndSend".prefix, %* [messageID])
proc editMessage*(messageId: string, contentType: int, msg: string): RpcResponse[JsonNode] =
result = callPrivateRPC("editMessage".prefix, %* [{"id": messageId, "text": msg, "content-type": contentType}])
proc editMessage*(messageId: string, msg: string): RpcResponse[JsonNode] =
result = callPrivateRPC("editMessage".prefix, %* [{"id": messageId, "text": msg}])
proc resendChatMessage*(messageId: string): RpcResponse[JsonNode] =
result = callPrivateRPC("reSendChatMessage".prefix, %* [messageId])

View File

@ -168,10 +168,10 @@ QtObject {
messageModule.setEditModeOff(messageId)
}
function editMessage(messageId, contentType, updatedMsg) {
function editMessage(messageId, updatedMsg) {
if(!messageModule)
return
messageModule.editMessage(messageId, contentType, updatedMsg)
messageModule.editMessage(messageId, updatedMsg)
}
function interpretMessage(msg) {

View File

@ -690,7 +690,6 @@ Loader {
root.messageStore.setEditModeOff(root.messageId)
root.messageStore.editMessage(
root.messageId,
Utils.isOnlyEmoji(message) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType,
interpretedMessage
)
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 34d2dafbd2a3f338feaa3b2d45b5e2c79341a4e3
Subproject commit 233f2f9a2afaf81e459f0025e390a6e58964ea5c