fix(MessageView): Ignore message editing with no actual changes

This commit is contained in:
Igor Sirotin 2022-12-21 18:04:25 +03:00 committed by Igor Sirotin
parent eb9f94630a
commit 784b9acd4f
3 changed files with 18 additions and 5 deletions

View File

@ -370,7 +370,7 @@ Control {
Layout.rightMargin: 16
active: root.editMode
visible: active
msgText: root.messageDetails.messageText
messageText: root.messageDetails.messageText
saveButtonText: root.saveButtonText
cancelButtonText: root.cancelButtonText
onEditCancelled: root.editCancelled()

View File

@ -13,7 +13,7 @@ Item {
property string cancelButtonText: ""
property string saveButtonText: ""
property string msgText: ""
property string messageText: ""
signal editCancelled()
signal editCompleted(var newMsgText)
@ -40,7 +40,7 @@ Item {
readonly property string messageText: input.text
width: parent.width
input.placeholderText: ""
input.text: msgText
input.text: root.messageText
maximumHeight: 40
}
}

View File

@ -432,17 +432,29 @@ Loader {
readonly property bool isReply: root.responseToMessageWithId !== ""
property var replyMessage: getReplyMessage()
readonly property string replySenderId: replyMessage ? replyMessage.senderId : ""
property string originalMessageText: ""
function getReplyMessage() {
return root.messageStore && isReply
? root.messageStore.getReplyMessageByIdAsJson(root.responseToMessageWithId)
: null
}
function editCancelledHandler() {
root.messageStore.setEditModeOff(root.messageId)
}
function editCompletedHandler(newMessageText) {
if (delegate.originalMessageText === newMessageText) {
delegate.editCancelledHandler()
return
}
const message = root.rootStore.plainText(StatusQUtils.Emoji.deparse(newMessageText))
if (message.length <= 0)
return;
@ -515,7 +527,7 @@ Loader {
messageAttachments: root.messageAttachments
onEditCancelled: {
root.messageStore.setEditModeOff(root.messageId)
delegate.editCancelledHandler()
}
onEditCompleted: {
@ -719,6 +731,7 @@ Loader {
Component.onCompleted: {
parseMessage(root.messageText);
delegate.originalMessageText = editTextInput.textInput.text
}
}