Change error msg when server URL may be invalid

This commit is contained in:
miruka 2019-11-11 06:57:33 -04:00
parent 7f48c1b35d
commit c9ddd4ee80

View File

@ -5,7 +5,8 @@ import "../Base"
HPage { HPage {
property string loginWith: "username" property string loginWith: "username"
readonly property bool canLogin: readonly property bool canLogin:
serverField.text && idField.text && passwordField.text serverField.text && idField.text && passwordField.text &&
! serverField.error
onFocusChanged: idField.forceActiveFocus() onFocusChanged: idField.forceActiveFocus()
@ -72,10 +73,15 @@ HPage {
id: loginTimeout id: loginTimeout
interval: 30 * 1000 interval: 30 * 1000
onTriggered: { onTriggered: {
errorMessage.text = qsTr( errorMessage.text =
"This server seems unavailable. Verify your internet " + serverField.knownServerChosen ?
"connection or try again in a few minutes."
) qsTr("This server seems unavailable. Verify your inter" +
"net connection or try again in a few minutes.") :
qsTr("This server seems unavailable. Verify the " +
"entered URL, your internet connection or try " +
"again in a few minutes.")
} }
} }
@ -104,8 +110,33 @@ HPage {
id: serverField id: serverField
placeholderText: qsTr("Homeserver URL") placeholderText: qsTr("Homeserver URL")
text: "https://matrix.org" text: "https://matrix.org"
error: ! /.+:\/\/.+/.test(cleanText)
Layout.fillWidth: true Layout.fillWidth: true
readonly property string cleanText: text.toLowerCase().trim()
// 2019-11-11 https://www.hello-matrix.net/public_servers.php
readonly property var knownServers: [
"https://matrix.org",
"https://chat.weho.st",
"https://tchncs.de",
"https://chat.privacytools.io",
"https://hackerspaces.be",
"https://matrix.allmende.io",
"https://feneas.org",
"https://junta.pl",
"https://perthchat.org",
"https://matrix.tedomum.net",
"https://converser.eu",
"https://ru-matrix.org",
"https://matrix.sibnsk.net",
"https://alternanet.fr",
]
readonly property bool knownServerChosen:
knownServers.includes(cleanText)
} }
HTextField { HTextField {