fix(links): fix editing a link and reflect what the new link shows
Fixes #3631
This commit is contained in:
parent
626541e3bd
commit
b335542dcd
|
@ -392,7 +392,12 @@ method editMessage*(self: Module, messageId: string, updatedMsg: string) =
|
|||
|
||||
method onMessageEdited*(self: Module, message: MessageDto) =
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
self.view.model().updateEditedMsg(message.id, renderedMessageText, message.containsContactMentions())
|
||||
self.view.model().updateEditedMsg(
|
||||
message.id,
|
||||
renderedMessageText,
|
||||
message.containsContactMentions(),
|
||||
message.links
|
||||
)
|
||||
|
||||
method onHistoryCleared*(self: Module) =
|
||||
self.view.model().clear()
|
||||
|
|
|
@ -210,6 +210,9 @@ proc removeReaction*(self: Item, emojiId: EmojiId, reactionId: string, didIRemov
|
|||
proc links*(self: Item): seq[string] {.inline.} =
|
||||
self.links
|
||||
|
||||
proc `links=`*(self: Item, links: seq[string]) {.inline.} =
|
||||
self.links = links
|
||||
|
||||
proc transactionParameters*(self: Item): TransactionParametersItem {.inline.} =
|
||||
self.transactionParameters
|
||||
|
||||
|
|
|
@ -362,7 +362,13 @@ QtObject:
|
|||
let index = self.createIndex(ind, 0, nil)
|
||||
self.dataChanged(index, index, @[ModelRole.EditMode.int])
|
||||
|
||||
proc updateEditedMsg*(self: Model, messageId: string, updatedMsg: string, messageContainsMentions: bool) =
|
||||
proc updateEditedMsg*(
|
||||
self: Model,
|
||||
messageId: string,
|
||||
updatedMsg: string,
|
||||
messageContainsMentions: bool,
|
||||
links: seq[string]
|
||||
) =
|
||||
let ind = self.findIndexForMessageId(messageId)
|
||||
if(ind == -1):
|
||||
return
|
||||
|
@ -370,9 +376,15 @@ QtObject:
|
|||
self.items[ind].messageText = updatedMsg
|
||||
self.items[ind].messageContainsMentions = messageContainsMentions
|
||||
self.items[ind].isEdited = true
|
||||
self.items[ind].links = links
|
||||
|
||||
let index = self.createIndex(ind, 0, nil)
|
||||
self.dataChanged(index, index, @[ModelRole.MessageText.int, ModelRole.MessageContainsMentions.int, ModelRole.IsEdited.int])
|
||||
self.dataChanged(index, index, @[
|
||||
ModelRole.MessageText.int,
|
||||
ModelRole.MessageContainsMentions.int,
|
||||
ModelRole.IsEdited.int,
|
||||
ModelRole.Links.int
|
||||
])
|
||||
|
||||
proc clear*(self: Model) =
|
||||
self.beginResetModel()
|
||||
|
|
|
@ -589,6 +589,7 @@ Item {
|
|||
Loader {
|
||||
id: linksLoader
|
||||
active: !!linkUrls
|
||||
height: item ? item.height : 0
|
||||
anchors.top: chatText.bottom
|
||||
anchors.topMargin: active ? Style.current.halfPadding : 0
|
||||
|
||||
|
|
|
@ -23,10 +23,14 @@ Column {
|
|||
property bool isCurrentUser: false
|
||||
property bool isImageLink: false
|
||||
spacing: Style.current.halfPadding
|
||||
height: childrenRect.height
|
||||
|
||||
ListModel {
|
||||
id: linksModel
|
||||
Component.onCompleted: {
|
||||
onLinkUrlsChanged: {
|
||||
root.prepareModel()
|
||||
}
|
||||
|
||||
function prepareModel() {
|
||||
linksModel.clear()
|
||||
if (!root.linkUrls) {
|
||||
return
|
||||
}
|
||||
|
@ -34,6 +38,12 @@ Column {
|
|||
linksModel.append({link})
|
||||
})
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: linksModel
|
||||
Component.onCompleted: {
|
||||
root.prepareModel()
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
|
|
Loading…
Reference in New Issue