From 2ff43ea801822b914117710751d90d808e26e1fd Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 22 Oct 2020 17:35:48 +1300 Subject: [PATCH] Style cleanup --- src/js/login.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/js/login.js b/src/js/login.js index 725ef4e..3bf23d0 100644 --- a/src/js/login.js +++ b/src/js/login.js @@ -71,7 +71,6 @@ class Form extends ElemJS { this.on("submit", this.submit.bind(this)) } - async submit() { if (this.processing) return this.processing = true @@ -114,32 +113,31 @@ class Form extends ElemJS { } async findHomeserver(address, maxDepth = 5) { - - //Protects us from servers sending us on a redirect loop + // Protects us from servers sending us on a redirect loop maxDepth-- - if(maxDepth<=0) throw new Error(`Failed to look up homeserver, maximum search depth reached`) - - //Preprocess the address + if (maxDepth <= 0) throw new Error(`Failed to look up homeserver, maximum search depth reached`) + + // Normalise the address if (!address.match(/^https?:\/\//)) { console.warn(`${address} doesn't specify the protocol, assuming https`) address = "https://" + address } address = address.replace(/\/*$/, "") - + this.status(`Looking up homeserver... trying ${address}`) - + // Check if we found the actual matrix server try { const versionsReq = await fetch(`${address}/_matrix/client/versions`) - if(versionsReq.ok) { + if (versionsReq.ok) { const versions = await versionsReq.json() if (Array.isArray(versions.versions)) { return address } } } catch(e) {} - - // find the next matrix server in the chain + + // Find the next matrix server in the chain const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => { console.error(e) throw new Error(`Failed to look up server ${address}`) @@ -155,7 +153,6 @@ class Form extends ElemJS { return this.findHomeserver(nextAddress, maxDepth) } - status(message) { feedback.setLoading(true) feedback.message(message) @@ -169,6 +166,3 @@ class Form extends ElemJS { } const form = new Form() - - -