Pass HTTPS server URL to Python when possible
Reduce the time it takes to connect to the server since Python won't need to guess the real protocol.
This commit is contained in:
parent
9cc9229fdb
commit
223197b84e
|
@ -11,12 +11,13 @@ import "../../ShortcutBundles"
|
||||||
HBox {
|
HBox {
|
||||||
id: box
|
id: box
|
||||||
|
|
||||||
|
property bool knownHttps: window.getState(box, "knownHttps", false)
|
||||||
property string acceptedUserUrl: ""
|
property string acceptedUserUrl: ""
|
||||||
property string acceptedUrl: ""
|
property string acceptedUrl: ""
|
||||||
property var loginFlows: []
|
property var loginFlows: []
|
||||||
|
|
||||||
property string saveName: "serverBrowser"
|
property string saveName: "serverBrowser"
|
||||||
property var saveProperties: ["acceptedUserUrl"]
|
property var saveProperties: ["acceptedUserUrl", "knownHttps"]
|
||||||
property string loadingIconStep: "server-ping-bad"
|
property string loadingIconStep: "server-ping-bad"
|
||||||
|
|
||||||
property Future connectFuture: null
|
property Future connectFuture: null
|
||||||
|
@ -41,7 +42,11 @@ HBox {
|
||||||
if (connectFuture) connectFuture.cancel()
|
if (connectFuture) connectFuture.cancel()
|
||||||
connectTimeout.restart()
|
connectTimeout.restart()
|
||||||
|
|
||||||
const args = [serverField.item.field.cleanText]
|
const typedUrl = serverField.item.field.cleanText
|
||||||
|
const args = [typedUrl]
|
||||||
|
|
||||||
|
if (box.knownHttps)
|
||||||
|
args[0] = args[0].replace(/^(https?:\/\/)?/, "https://")
|
||||||
|
|
||||||
connectFuture = py.callCoro("server_info", args, ([url, flows]) => {
|
connectFuture = py.callCoro("server_info", args, ([url, flows]) => {
|
||||||
connectTimeout.stop()
|
connectTimeout.stop()
|
||||||
|
@ -61,7 +66,7 @@ HBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptedUrl = url
|
acceptedUrl = url
|
||||||
acceptedUserUrl = String(args[0])
|
acceptedUserUrl = typedUrl
|
||||||
loginFlows = flows
|
loginFlows = flows
|
||||||
accepted()
|
accepted()
|
||||||
|
|
||||||
|
@ -164,6 +169,7 @@ HBox {
|
||||||
py.callCoro(
|
py.callCoro(
|
||||||
"set_string_filter", ["filtered_homeservers", text],
|
"set_string_filter", ["filtered_homeservers", text],
|
||||||
)
|
)
|
||||||
|
knownHttps = false
|
||||||
serverList.currentIndex = -1
|
serverList.currentIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +258,9 @@ HBox {
|
||||||
id: serverList
|
id: serverList
|
||||||
|
|
||||||
function setFieldText(fromItemIndex) {
|
function setFieldText(fromItemIndex) {
|
||||||
serverField.item.field.text =
|
const url = model.get(fromItemIndex).id
|
||||||
model.get(fromItemIndex).id.replace(/^https:\/\//, "")
|
box.knownHttps = /^https:\/\//.test(url)
|
||||||
|
serverField.item.field.text = url.replace(/^https:\/\//, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user