mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-21 19:18:53 +00:00
fix(MessageView): Ignore message editing with no actual changes
This commit is contained in:
parent
eb9f94630a
commit
784b9acd4f
@ -370,7 +370,7 @@ Control {
|
|||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
active: root.editMode
|
active: root.editMode
|
||||||
visible: active
|
visible: active
|
||||||
msgText: root.messageDetails.messageText
|
messageText: root.messageDetails.messageText
|
||||||
saveButtonText: root.saveButtonText
|
saveButtonText: root.saveButtonText
|
||||||
cancelButtonText: root.cancelButtonText
|
cancelButtonText: root.cancelButtonText
|
||||||
onEditCancelled: root.editCancelled()
|
onEditCancelled: root.editCancelled()
|
||||||
|
@ -13,7 +13,7 @@ Item {
|
|||||||
|
|
||||||
property string cancelButtonText: ""
|
property string cancelButtonText: ""
|
||||||
property string saveButtonText: ""
|
property string saveButtonText: ""
|
||||||
property string msgText: ""
|
property string messageText: ""
|
||||||
|
|
||||||
signal editCancelled()
|
signal editCancelled()
|
||||||
signal editCompleted(var newMsgText)
|
signal editCompleted(var newMsgText)
|
||||||
@ -40,7 +40,7 @@ Item {
|
|||||||
readonly property string messageText: input.text
|
readonly property string messageText: input.text
|
||||||
width: parent.width
|
width: parent.width
|
||||||
input.placeholderText: ""
|
input.placeholderText: ""
|
||||||
input.text: msgText
|
input.text: root.messageText
|
||||||
maximumHeight: 40
|
maximumHeight: 40
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,17 +432,29 @@ Loader {
|
|||||||
readonly property bool isReply: root.responseToMessageWithId !== ""
|
readonly property bool isReply: root.responseToMessageWithId !== ""
|
||||||
|
|
||||||
property var replyMessage: getReplyMessage()
|
property var replyMessage: getReplyMessage()
|
||||||
|
|
||||||
readonly property string replySenderId: replyMessage ? replyMessage.senderId : ""
|
readonly property string replySenderId: replyMessage ? replyMessage.senderId : ""
|
||||||
|
|
||||||
|
property string originalMessageText: ""
|
||||||
|
|
||||||
function getReplyMessage() {
|
function getReplyMessage() {
|
||||||
return root.messageStore && isReply
|
return root.messageStore && isReply
|
||||||
? root.messageStore.getReplyMessageByIdAsJson(root.responseToMessageWithId)
|
? root.messageStore.getReplyMessageByIdAsJson(root.responseToMessageWithId)
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editCancelledHandler() {
|
||||||
|
root.messageStore.setEditModeOff(root.messageId)
|
||||||
|
}
|
||||||
|
|
||||||
function editCompletedHandler(newMessageText) {
|
function editCompletedHandler(newMessageText) {
|
||||||
|
|
||||||
|
if (delegate.originalMessageText === newMessageText) {
|
||||||
|
delegate.editCancelledHandler()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const message = root.rootStore.plainText(StatusQUtils.Emoji.deparse(newMessageText))
|
const message = root.rootStore.plainText(StatusQUtils.Emoji.deparse(newMessageText))
|
||||||
|
|
||||||
if (message.length <= 0)
|
if (message.length <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -515,7 +527,7 @@ Loader {
|
|||||||
messageAttachments: root.messageAttachments
|
messageAttachments: root.messageAttachments
|
||||||
|
|
||||||
onEditCancelled: {
|
onEditCancelled: {
|
||||||
root.messageStore.setEditModeOff(root.messageId)
|
delegate.editCancelledHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditCompleted: {
|
onEditCompleted: {
|
||||||
@ -719,6 +731,7 @@ Loader {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
parseMessage(root.messageText);
|
parseMessage(root.messageText);
|
||||||
|
delegate.originalMessageText = editTextInput.textInput.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user