diff --git a/skins/base/views/templates/Login.js b/skins/base/views/templates/Login.js
index f71e30706..ba75e5d1c 100644
--- a/skins/base/views/templates/Login.js
+++ b/skins/base/views/templates/Login.js
@@ -28,15 +28,44 @@ var LoginController = require("../../../../src/controllers/templates/Login");
var ServerConfig = ComponentBroker.get("molecules/ServerConfig");
module.exports = React.createClass({
+ DEFAULT_HS_URL: 'https://matrix.org',
+ DEFAULT_IS_URL: 'https://matrix.org',
+
displayName: 'Login',
mixins: [LoginController],
+ getInitialState: function() {
+ return {
+ serverConfigVisible: false
+ };
+ },
+
+ componentWillMount: function() {
+ this.onHSChosen();
+ this.customHsUrl = this.DEFAULT_HS_URL;
+ this.customIsUrl = this.DEFAULT_IS_URL;
+ },
+
getHsUrl: function() {
- return this.refs.serverConfig.getHsUrl();
+ if (this.state.serverConfigVisible) {
+ return this.refs.serverConfig.getHsUrl();
+ } else {
+ return this.DEFAULT_HS_URL;
+ }
},
getIsUrl: function() {
- return this.refs.serverConfig.getIsUrl();
+ if (this.state.serverConfigVisible) {
+ return this.refs.serverConfig.getIsUrl();
+ } else {
+ return this.DEFAULT_IS_URL;
+ }
+ },
+
+ onServerConfigVisibleChange: function(ev) {
+ this.setState({
+ serverConfigVisible: ev.target.checked
+ });
},
/**
@@ -49,15 +78,35 @@ module.exports = React.createClass({
};
},
+ onHsUrlChanged: function() {
+ this.customHsUrl = this.getHsUrl();
+ this.customIsUrl = this.getIsUrl();
+ if (this.updateHsTimeout) {
+ clearTimeout(this.updateHsTimeout);
+ }
+ /*var self = this;
+ this.updateHsTimeout = setTimeout(function() {
+ self.onHSChosen();
+ }, 500);*/
+ },
+
componentForStep: function(step) {
switch (step) {
case 'choose_hs':
+ var serverConfigStyle = {};
+ if (!this.state.serverConfigVisible) {
+ serverConfigStyle.display = 'none';
+ }
return (
-
+
+ Use custom server options (advanced)
+
+
+
);
// XXX: clearly these should be separate organisms
@@ -67,6 +116,7 @@ module.exports = React.createClass({
@@ -94,7 +144,6 @@ module.exports = React.createClass({
render: function() {
return (
);
diff --git a/skins/base/views/templates/Register.js b/skins/base/views/templates/Register.js
index 930228b8b..233673786 100644
--- a/skins/base/views/templates/Register.js
+++ b/skins/base/views/templates/Register.js
@@ -39,6 +39,11 @@ module.exports = React.createClass({
};
},
+ componentWillMount: function() {
+ this.customHsUrl = this.DEFAULT_HS_URL;
+ this.customIsUrl = this.DEFAULT_IS_URL;
+ },
+
getRegFormVals: function() {
return {
email: this.refs.email.getDOMNode().value,
@@ -50,7 +55,7 @@ module.exports = React.createClass({
getHsUrl: function() {
if (this.state.serverConfigVisible) {
- return this.refs.serverConfig.getHsUrl();
+ return this.customHsUrl;
} else {
return this.DEFAULT_HS_URL;
}
@@ -58,7 +63,7 @@ module.exports = React.createClass({
getIsUrl: function() {
if (this.state.serverConfigVisible) {
- return this.refs.serverConfig.getIsUrl();
+ return this.customIsUrl;
} else {
return this.DEFAULT_IS_URL;
}
@@ -82,6 +87,8 @@ module.exports = React.createClass({
},
onServerUrlChanged: function(newUrl) {
+ this.customHsUrl = this.refs.serverConfig.getHsUrl();
+ this.customIsUrl = this.refs.serverConfig.getIsUrl();
this.forceUpdate();
},
@@ -104,7 +111,7 @@ module.exports = React.createClass({
Use custom server options (advanced)
diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js
index 07ace740d..3d25a9106 100644
--- a/src/controllers/templates/Login.js
+++ b/src/controllers/templates/Login.js
@@ -38,8 +38,7 @@ module.exports = {
this.setState({ step: step, errorText: '', busy: false });
},
- onHSChosen: function(ev) {
- ev.preventDefault();
+ onHSChosen: function() {
MatrixClientPeg.replaceUsingUrls(
this.getHsUrl(),
this.getIsUrl()