From 19b31ff30df01c4a7037424f8c22fd6c862719bb Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 11 Nov 2015 00:06:49 +0100 Subject: [PATCH] oops, make this actually work. --- src/skins/vector/views/templates/Login.js | 19 +++++++------- src/skins/vector/views/templates/Register.js | 26 +++++++++++++------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/skins/vector/views/templates/Login.js b/src/skins/vector/views/templates/Login.js index 702043c6..e01bd1f7 100644 --- a/src/skins/vector/views/templates/Login.js +++ b/src/skins/vector/views/templates/Login.js @@ -29,23 +29,22 @@ module.exports = React.createClass({ displayName: 'Login', mixins: [LoginController], - componentWillMount: function() { + getInitialState: function() { // TODO: factor out all localstorage stuff into its own home. // This is common to Login, Register and MatrixClientPeg var localStorage = window.localStorage; + var hs_url, is_url; if (localStorage) { - var hs_url = localStorage.getItem("mx_hs_url"); - var is_url = localStorage.getItem("mx_is_url"); + hs_url = localStorage.getItem("mx_hs_url"); + is_url = localStorage.getItem("mx_is_url"); } - this.setState({ + return { customHsUrl: hs_url || config.default_hs_url, customIsUrl: is_url || config.default_is_url, - serverConfigVisible: (hs_url !== config.default_hs_url || - is_url !== config.default_is_url) - }); - - this.onHSChosen(); + serverConfigVisible: (hs_url && hs_url !== config.default_hs_url || + is_url && is_url !== config.default_is_url) + } }, getHsUrl: function() { @@ -147,7 +146,7 @@ module.exports = React.createClass({ return (
-
+

{ this.componentForStep('choose_hs') } diff --git a/src/skins/vector/views/templates/Register.js b/src/skins/vector/views/templates/Register.js index 28ae9ffc..945d607c 100644 --- a/src/skins/vector/views/templates/Register.js +++ b/src/skins/vector/views/templates/Register.js @@ -29,21 +29,29 @@ module.exports = React.createClass({ displayName: 'Register', mixins: [RegisterController], - componentWillMount: function() { + getInitialState: function() { // TODO: factor out all localstorage stuff into its own home. // This is common to Login, Register and MatrixClientPeg var localStorage = window.localStorage; + var hs_url, is_url; if (localStorage) { - var hs_url = localStorage.getItem("mx_hs_url"); - var is_url = localStorage.getItem("mx_is_url"); + hs_url = localStorage.getItem("mx_hs_url"); + is_url = localStorage.getItem("mx_is_url"); } - this.setState({ + // make sure we have our MatrixClient set up whatever + // Useful for debugging only. + // MatrixClientPeg.replaceUsingUrls( + // hs_url || config.default_hs_url, + // is_url || config.default_is_url + // ); + + return { customHsUrl: hs_url || config.default_hs_url, customIsUrl: is_url || config.default_is_url, - serverConfigVisible: (hs_url !== config.default_hs_url || - is_url !== config.default_is_url) - }); + serverConfigVisible: (hs_url && hs_url !== config.default_hs_url || + is_url && is_url !== config.default_is_url) + } }, getRegFormVals: function() { @@ -98,12 +106,12 @@ module.exports = React.createClass({ return (
-
+



- +