mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Check with regex everywhere
This commit is contained in:
parent
92fdda8423
commit
823e740396
1 changed files with 6 additions and 4 deletions
|
@ -15,14 +15,14 @@ ApplicationWindow {
|
||||||
property InviteesModel invitees
|
property InviteesModel invitees
|
||||||
|
|
||||||
function addInvite() {
|
function addInvite() {
|
||||||
if (inviteeEntry.text.match("@.+?:.{3,}")) {
|
if (inviteeEntry.isValidMxid) {
|
||||||
invitees.addUser(inviteeEntry.text);
|
invitees.addUser(inviteeEntry.text);
|
||||||
inviteeEntry.clear();
|
inviteeEntry.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanUpAndClose() {
|
function cleanUpAndClose() {
|
||||||
if (inviteeEntry.text.match("@.+?:.{3,}"))
|
if (inviteeEntry.isValidMxid)
|
||||||
addInvite();
|
addInvite();
|
||||||
|
|
||||||
invitees.accept();
|
invitees.accept();
|
||||||
|
@ -63,11 +63,13 @@ ApplicationWindow {
|
||||||
MatrixTextField {
|
MatrixTextField {
|
||||||
id: inviteeEntry
|
id: inviteeEntry
|
||||||
|
|
||||||
|
property bool isValidMxid: text.match("@.+?:.{3,}")
|
||||||
|
|
||||||
backgroundColor: Nheko.colors.window
|
backgroundColor: Nheko.colors.window
|
||||||
placeholderText: qsTr("@joe:matrix.org", "Example user id. The name 'joe' can be localized however you want.")
|
placeholderText: qsTr("@joe:matrix.org", "Example user id. The name 'joe' can be localized however you want.")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (text !== "")
|
if (isValidMxid)
|
||||||
addInvite();
|
addInvite();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,7 +84,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Add")
|
text: qsTr("Add")
|
||||||
enabled: inviteeEntry.text.match("@.+?:.{3,}")
|
enabled: inviteeEntry.isValidMxid
|
||||||
onClicked: addInvite()
|
onClicked: addInvite()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue