[#2376] Removed invalid error message when adding new contact
* Also removed from adding new chat Closes #2376
This commit is contained in:
parent
b31bd265c5
commit
d866a9f59e
|
@ -135,9 +135,9 @@ Item {
|
||||||
} else if (profileModel.profile.pubKey === value) {
|
} else if (profileModel.profile.pubKey === value) {
|
||||||
addContactModal.validationError = qsTr("You can't add yourself");
|
addContactModal.validationError = qsTr("You can't add yourself");
|
||||||
} else {
|
} else {
|
||||||
addContactModal.validationError = ""
|
addContactModal.validationError = "";
|
||||||
}
|
}
|
||||||
return addContactModal.validationError === ""
|
return addContactModal.validationError === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
|
property var lookupContact: Backpressure.debounce(addContactSearchInput, 400, function (value) {
|
||||||
|
@ -158,13 +158,17 @@ Item {
|
||||||
customHeight: 44
|
customHeight: 44
|
||||||
fontPixelSize: 15
|
fontPixelSize: 15
|
||||||
Keys.onReleased: {
|
Keys.onReleased: {
|
||||||
|
if (text !== "") {
|
||||||
if (!addContactModal.validate(addContactSearchInput.text)) {
|
if (!addContactModal.validate(addContactSearchInput.text)) {
|
||||||
searchResults.reset()
|
searchResults.reset();
|
||||||
contactsContainer.isPending = false
|
contactsContainer.isPending = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt.callLater(addContactModal.lookupContact, addContactSearchInput.text)
|
Qt.callLater(addContactModal.lookupContact, addContactSearchInput.text);
|
||||||
|
} else {
|
||||||
|
addContactModal.validationError = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,16 +34,16 @@ Item {
|
||||||
function validate() {
|
function validate() {
|
||||||
if (!Utils.isChatKey(chatKey.text) && !Utils.isValidETHNamePrefix(chatKey.text)) {
|
if (!Utils.isChatKey(chatKey.text) && !Utils.isValidETHNamePrefix(chatKey.text)) {
|
||||||
//% "Enter a valid chat key or ENS username"
|
//% "Enter a valid chat key or ENS username"
|
||||||
validationError = qsTrId("enter-a-valid-chat-key-or-ens-username");
|
root.validationError = "enter-a-valid-chat-key-or-ens-username";
|
||||||
pubKey = ""
|
pubKey = ""
|
||||||
ensUsername = "";
|
ensUsername = "";
|
||||||
} else if (profileModel.profile.pubKey === chatKey.text) {
|
} else if (profileModel.profile.pubKey === chatKey.text) {
|
||||||
//% "Can't chat with yourself"
|
//% "Can't chat with yourself"
|
||||||
validationError = qsTrId("can-t-chat-with-yourself");
|
root.validationError = qsTrId("can-t-chat-with-yourself");
|
||||||
} else {
|
} else {
|
||||||
validationError = ""
|
root.validationError = "";
|
||||||
}
|
}
|
||||||
return validationError === ""
|
return root.validationError === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Input {
|
Input {
|
||||||
|
@ -51,11 +51,12 @@ Item {
|
||||||
//% "Enter ENS username or chat key"
|
//% "Enter ENS username or chat key"
|
||||||
placeholderText: qsTrId("enter-contact-code")
|
placeholderText: qsTrId("enter-contact-code")
|
||||||
Keys.onReleased: {
|
Keys.onReleased: {
|
||||||
successMessage = ""
|
successMessage = "";
|
||||||
searchResults.pubKey = ""
|
searchResults.pubKey = "";
|
||||||
|
if (chatKey.text !== "") {
|
||||||
if (!validate()) {
|
if (!validate()) {
|
||||||
searchResults.showProfileNotFoundMessage = false
|
searchResults.showProfileNotFoundMessage = false;
|
||||||
noContactsRect.visible = false
|
noContactsRect.visible = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,15 +65,18 @@ Item {
|
||||||
if (Utils.isChatKey(chatKey.text)) {
|
if (Utils.isChatKey(chatKey.text)) {
|
||||||
pubKey = chatKey.text;
|
pubKey = chatKey.text;
|
||||||
if (!profileModel.contacts.isAdded(pubKey)) {
|
if (!profileModel.contacts.isAdded(pubKey)) {
|
||||||
searchResults.username = utilsModel.generateAlias(pubKey)
|
searchResults.username = utilsModel.generateAlias(pubKey);
|
||||||
searchResults.userAlias = Utils.compactAddress(pubKey, 4)
|
searchResults.userAlias = Utils.compactAddress(pubKey, 4);
|
||||||
searchResults.pubKey = pubKey
|
searchResults.pubKey = pubKey
|
||||||
}
|
}
|
||||||
noContactsRect.visible = false
|
noContactsRect.visible = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt.callLater(resolveENS, chatKey.text)
|
Qt.callLater(resolveENS, chatKey.text);
|
||||||
|
} else {
|
||||||
|
root.validationError = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
textField.anchors.rightMargin: clearBtn.width + Style.current.padding + 2
|
textField.anchors.rightMargin: clearBtn.width + Style.current.padding + 2
|
||||||
|
|
||||||
|
@ -90,7 +94,7 @@ Item {
|
||||||
} else {
|
} else {
|
||||||
if (profileModel.profile.pubKey === resolvedPubKey) {
|
if (profileModel.profile.pubKey === resolvedPubKey) {
|
||||||
//% "Can't chat with yourself"
|
//% "Can't chat with yourself"
|
||||||
validationError = qsTrId("can-t-chat-with-yourself");
|
root.validationError = qsTrId("can-t-chat-with-yourself");
|
||||||
} else {
|
} else {
|
||||||
searchResults.username = chatsModel.ensView.formatENSUsername(chatKey.text)
|
searchResults.username = chatsModel.ensView.formatENSUsername(chatKey.text)
|
||||||
let userAlias = utilsModel.generateAlias(resolvedPubKey)
|
let userAlias = utilsModel.generateAlias(resolvedPubKey)
|
||||||
|
@ -119,23 +123,23 @@ Item {
|
||||||
anchors.rightMargin: Style.current.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
onClicked: {
|
onClicked: {
|
||||||
chatKey.text = ""
|
chatKey.text = "";
|
||||||
chatKey.forceActiveFocus(Qt.MouseFocusReason)
|
chatKey.forceActiveFocus(Qt.MouseFocusReason);
|
||||||
searchResults.showProfileNotFoundMessage = false
|
searchResults.showProfileNotFoundMessage = false;
|
||||||
searchResults.pubKey = pubKey = ""
|
searchResults.pubKey = pubKey = "";
|
||||||
noContactsRect.visible = false
|
noContactsRect.visible = false;
|
||||||
searchResults.loading = false
|
searchResults.loading = false;
|
||||||
validationError = ""
|
root.validationError = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: message
|
id: message
|
||||||
text: validationError || successMessage
|
text: root.validationError || successMessage
|
||||||
visible: validationError !== "" || successMessage !== ""
|
visible: root.validationError !== "" || successMessage !== ""
|
||||||
font.pixelSize: 13
|
font.pixelSize: 13
|
||||||
color: !!validationError ? Style.current.danger : Style.current.success
|
color: !!root.validationError ? Style.current.danger : Style.current.success
|
||||||
anchors.top: chatKey.bottom
|
anchors.top: chatKey.bottom
|
||||||
anchors.topMargin: Style.current.smallPadding
|
anchors.topMargin: Style.current.smallPadding
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
Loading…
Reference in New Issue