Fix inactive "Send Arrow" in smsapp after first message sent

The "enabled" property of the button was set to false and has overwritten the default value based on the message length.
The message field had "anchors.fill" positioning and raised  "Binding loop detected for property "implicitHeight"" error.
attachmentList property of ChatMessage didn't have the default value and was undefined.

BUG: 455149
This commit is contained in:
Dmytrii Zavalnyi 2023-04-21 16:28:58 +00:00 committed by Simon Redman
parent ccb4a62f9c
commit 0d02a6f99e
2 changed files with 14 additions and 11 deletions

View file

@ -21,7 +21,7 @@ Item {
property date dateTime
property string name
property bool multiTarget
property var attachmentList
property var attachmentList: []
signal messageCopyRequested(string message)

View file

@ -68,7 +68,7 @@ ColumnLayout {
Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff
Controls.TextArea {
anchors.fill: parent
width: parent.width
id: messageField
placeholderText: i18nd("kdeconnect-sms", "Compose message")
wrapMode: TextEdit.Wrap
@ -144,15 +144,14 @@ ColumnLayout {
onClicked: {
selectedFileUrls = []
if (messageField.text == "") {
sendButton.enabled = false
}
}
}
Controls.ToolButton {
property bool isSendingInProcess: false
id: sendButton
enabled: messageField.text.length || selectedFileUrls.length
enabled: (messageField.text.length || selectedFileUrls.length) && !isSendingInProcess
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
padding: 0
@ -169,9 +168,13 @@ ColumnLayout {
property bool messageSent: false
onClicked: {
// disable the button to prevent sending
// the same message several times
sendButton.enabled = false
// prevent sending the same message several times
// and don't touch enabled property
if (isSendingInProcess){
return;
}
isSendingInProcess = true
if (SmsHelper.totalMessageSize(selectedFileUrls, messageField.text) > maxMessageSize) {
messageDialog.visible = true
@ -184,14 +187,14 @@ ColumnLayout {
if (messageSent) {
messageField.text = ""
selectedFileUrls = []
sendButton.enabled = false
}
isSendingInProcess = false
}
}
}
Controls.Label {
id: "charCount"
id: charCount
text: conversationModel.getCharCountInfo(messageField.text)
visible: text.length > 0
Layout.minimumWidth: Math.max(Layout.minimumWidth, width) // Make this label only grow, never shrink