fix(@dekstop/chat): editing a message does not update the reply
Fixes #4891
This commit is contained in:
parent
4ff700681f
commit
9821e160c1
|
@ -421,6 +421,13 @@ method onMessageEdited*(self: Module, message: MessageDto) =
|
||||||
message.links
|
message.links
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let messagesIds = self.view.model().findIdsOfTheMessagesWhichRespondedToMessageWithId(message.id)
|
||||||
|
for msgId in messagesIds:
|
||||||
|
# refreshing an item calling `self.view.model().refreshItemWithId(msgId)` doesn't work from some very weird reason
|
||||||
|
# and that would be the correct way of updating item instead sending this signal. We should check this once we refactor
|
||||||
|
# qml part.
|
||||||
|
self.view.emitRefreshAMessageUserRespondedToSignal(msgId)
|
||||||
|
|
||||||
method onHistoryCleared*(self: Module) =
|
method onHistoryCleared*(self: Module) =
|
||||||
self.view.model().clear()
|
self.view.model().clear()
|
||||||
|
|
||||||
|
|
|
@ -161,4 +161,8 @@ QtObject:
|
||||||
self.delegate.leaveChat()
|
self.delegate.leaveChat()
|
||||||
|
|
||||||
proc didIJoinedChat(self: View): bool {.slot.} =
|
proc didIJoinedChat(self: View): bool {.slot.} =
|
||||||
return self.delegate.didIJoinedChat()
|
return self.delegate.didIJoinedChat()
|
||||||
|
|
||||||
|
proc refreshAMessageUserRespondedTo(self: View, msgId: string) {.signal.}
|
||||||
|
proc emitRefreshAMessageUserRespondedToSignal*(self: View, msgId: string) =
|
||||||
|
self.refreshAMessageUserRespondedTo(msgId)
|
|
@ -196,6 +196,11 @@ QtObject:
|
||||||
return i
|
return i
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
proc findIdsOfTheMessagesWhichRespondedToMessageWithId*(self: Model, messageId: string): seq[string] =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
if(self.items[i].responseToMessageWithId == messageId):
|
||||||
|
result.add(self.items[i].id)
|
||||||
|
|
||||||
proc findIndexBasedOnTimestampToInsertTo(self: Model, timestamp: int64): int =
|
proc findIndexBasedOnTimestampToInsertTo(self: Model, timestamp: int64): int =
|
||||||
for i in 0 ..< self.items.len:
|
for i in 0 ..< self.items.len:
|
||||||
if(timestamp > self.items[i].timestamp):
|
if(timestamp > self.items[i].timestamp):
|
||||||
|
|
|
@ -248,6 +248,7 @@ Item {
|
||||||
isChatBlocked: root.isChatBlocked
|
isChatBlocked: root.isChatBlocked
|
||||||
messageContextMenu: messageContextMenuInst
|
messageContextMenu: messageContextMenuInst
|
||||||
|
|
||||||
|
itemIndex: index
|
||||||
messageId: model.id
|
messageId: model.id
|
||||||
communityId: model.communityId
|
communityId: model.communityId
|
||||||
responseToMessageWithId: model.responseToMessageWithId
|
responseToMessageWithId: model.responseToMessageWithId
|
||||||
|
|
|
@ -74,6 +74,15 @@ Item {
|
||||||
height: messageContainer.height + messageContainer.anchors.topMargin
|
height: messageContainer.height + messageContainer.anchors.topMargin
|
||||||
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
|
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.messageStore.messageModule
|
||||||
|
enabled: responseTo !== ""
|
||||||
|
onRefreshAMessageUserRespondedTo: {
|
||||||
|
if(msgId === messageId)
|
||||||
|
chatReply.resetOriginalMessage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: ensureMessageFullyVisibleTimer
|
id: ensureMessageFullyVisibleTimer
|
||||||
interval: 1
|
interval: 1
|
||||||
|
@ -283,7 +292,7 @@ Item {
|
||||||
// stickerData: !!rootStore ? rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker") : null
|
// stickerData: !!rootStore ? rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker") : null
|
||||||
active: responseTo !== "" && !activityCenterMessage
|
active: responseTo !== "" && !activityCenterMessage
|
||||||
|
|
||||||
Component.onCompleted: {
|
function resetOriginalMessage() {
|
||||||
if(!root.messageStore)
|
if(!root.messageStore)
|
||||||
return
|
return
|
||||||
let obj = root.messageStore.getMessageByIdAsJson(responseTo)
|
let obj = root.messageStore.getMessageByIdAsJson(responseTo)
|
||||||
|
@ -300,6 +309,11 @@ Item {
|
||||||
repliedMessageContent = obj.messageText
|
repliedMessageContent = obj.messageText
|
||||||
repliedMessageImage = obj.messageImage
|
repliedMessageImage = obj.messageImage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
resetOriginalMessage()
|
||||||
|
}
|
||||||
|
|
||||||
onScrollToBottom: {
|
onScrollToBottom: {
|
||||||
// Not Refactored Yet
|
// Not Refactored Yet
|
||||||
// messageStore.scrollToBottom(isit, root.container);
|
// messageStore.scrollToBottom(isit, root.container);
|
||||||
|
|
|
@ -27,6 +27,7 @@ Column {
|
||||||
// without an explicit need to fetch those details via message store/module.
|
// without an explicit need to fetch those details via message store/module.
|
||||||
property bool isChatBlocked: false
|
property bool isChatBlocked: false
|
||||||
|
|
||||||
|
property int itemIndex: -1
|
||||||
property string messageId: ""
|
property string messageId: ""
|
||||||
property string communityId: ""
|
property string communityId: ""
|
||||||
property string responseToMessageWithId: ""
|
property string responseToMessageWithId: ""
|
||||||
|
|
Loading…
Reference in New Issue