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) =
|
method onMessageEdited*(self: Module, message: MessageDto) =
|
||||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
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) =
|
method onHistoryCleared*(self: Module) =
|
||||||
self.view.model().clear()
|
self.view.model().clear()
|
||||||
|
|
|
@ -210,6 +210,9 @@ proc removeReaction*(self: Item, emojiId: EmojiId, reactionId: string, didIRemov
|
||||||
proc links*(self: Item): seq[string] {.inline.} =
|
proc links*(self: Item): seq[string] {.inline.} =
|
||||||
self.links
|
self.links
|
||||||
|
|
||||||
|
proc `links=`*(self: Item, links: seq[string]) {.inline.} =
|
||||||
|
self.links = links
|
||||||
|
|
||||||
proc transactionParameters*(self: Item): TransactionParametersItem {.inline.} =
|
proc transactionParameters*(self: Item): TransactionParametersItem {.inline.} =
|
||||||
self.transactionParameters
|
self.transactionParameters
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,13 @@ QtObject:
|
||||||
let index = self.createIndex(ind, 0, nil)
|
let index = self.createIndex(ind, 0, nil)
|
||||||
self.dataChanged(index, index, @[ModelRole.EditMode.int])
|
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)
|
let ind = self.findIndexForMessageId(messageId)
|
||||||
if(ind == -1):
|
if(ind == -1):
|
||||||
return
|
return
|
||||||
|
@ -370,9 +376,15 @@ QtObject:
|
||||||
self.items[ind].messageText = updatedMsg
|
self.items[ind].messageText = updatedMsg
|
||||||
self.items[ind].messageContainsMentions = messageContainsMentions
|
self.items[ind].messageContainsMentions = messageContainsMentions
|
||||||
self.items[ind].isEdited = true
|
self.items[ind].isEdited = true
|
||||||
|
self.items[ind].links = links
|
||||||
|
|
||||||
let index = self.createIndex(ind, 0, nil)
|
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) =
|
proc clear*(self: Model) =
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
|
|
|
@ -589,6 +589,7 @@ Item {
|
||||||
Loader {
|
Loader {
|
||||||
id: linksLoader
|
id: linksLoader
|
||||||
active: !!linkUrls
|
active: !!linkUrls
|
||||||
|
height: item ? item.height : 0
|
||||||
anchors.top: chatText.bottom
|
anchors.top: chatText.bottom
|
||||||
anchors.topMargin: active ? Style.current.halfPadding : 0
|
anchors.topMargin: active ? Style.current.halfPadding : 0
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,14 @@ Column {
|
||||||
property bool isCurrentUser: false
|
property bool isCurrentUser: false
|
||||||
property bool isImageLink: false
|
property bool isImageLink: false
|
||||||
spacing: Style.current.halfPadding
|
spacing: Style.current.halfPadding
|
||||||
|
height: childrenRect.height
|
||||||
|
|
||||||
ListModel {
|
onLinkUrlsChanged: {
|
||||||
id: linksModel
|
root.prepareModel()
|
||||||
Component.onCompleted: {
|
}
|
||||||
|
|
||||||
|
function prepareModel() {
|
||||||
|
linksModel.clear()
|
||||||
if (!root.linkUrls) {
|
if (!root.linkUrls) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,6 +38,12 @@ Column {
|
||||||
linksModel.append({link})
|
linksModel.append({link})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListModel {
|
||||||
|
id: linksModel
|
||||||
|
Component.onCompleted: {
|
||||||
|
root.prepareModel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
|
Loading…
Reference in New Issue