diff --git a/css/templates/Login.css b/css/templates/Login.css index 10c28d7c..4596edd1 100644 --- a/css/templates/Login.css +++ b/css/templates/Login.css @@ -7,5 +7,6 @@ text-align: center; background-color: #eee; border: 1px solid black; + position: relative; } diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index ee417174..eed8093a 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -14,6 +14,7 @@ if (localStorage) { accessToken: access_token, userId: user_id }); + matrixClient.startClient(); } } diff --git a/src/pages/MatrixChat.js b/src/pages/MatrixChat.js index 01b9ebe2..0395450f 100644 --- a/src/pages/MatrixChat.js +++ b/src/pages/MatrixChat.js @@ -7,24 +7,27 @@ var Login = require('../templates/Login'); var mxCliPeg = require("../MatrixClientPeg"); -var dis = require("../dispatcher"); +//var dis = require("../dispatcher"); module.exports = React.createClass({ getInitialState: function() { return { - logged_in: !!mxCliPeg.get().credentials + logged_in: !!(mxCliPeg.get() && mxCliPeg.get().credentials) }; }, - componentWillMount: function() { + /*componentWillMount: function() { var that = this; this.dispatcherRef = dis.register(function(payload) { switch(payload.action) { case 'logged_in': - that.setState({logged_in: true}); break; } }); + },*/ + + onLoggedIn: function() { + this.setState({logged_in: true}); }, render: function() { @@ -37,7 +40,7 @@ module.exports = React.createClass({ ); } else { return ( - + ); } } diff --git a/src/templates/Login.js b/src/templates/Login.js index 77518bb1..0700a3d0 100644 --- a/src/templates/Login.js +++ b/src/templates/Login.js @@ -6,7 +6,7 @@ var ServerConfig = require("../molecules/ServerConfig"); var ProgressBar = require("../molecules/ProgressBar"); var Loader = require("react-loader"); -var dis = require("../dispatcher"); +//var dis = require("../dispatcher"); module.exports = React.createClass({ getInitialState: function() { @@ -19,7 +19,7 @@ module.exports = React.createClass({ }, setStep: function(step) { - this.setState({ step: step, errorText: '' }); + this.setState({ step: step, errorText: '', busy: false }); }, onHSChosen: function(ev) { @@ -50,6 +50,11 @@ module.exports = React.createClass({ 'password': that.refs.pass.getDOMNode().value }).then(function(data) { // XXX: we assume this means we're logged in, but there could be a next stage + MatrixClientPeg.replace(Matrix.createClient({ + baseUrl: that.state.hs_url, + userId: data.user_id, + accessToken: data.access_token + })); var localStorage = window.localStorage; if (localStorage) { localStorage.setItem("mx_hs_url", that.state.hs_url); @@ -58,9 +63,12 @@ module.exports = React.createClass({ } else { console.warn("No local storage available: can't persist session!"); } - dis.dispatch({ + if (that.props.onLoggedIn) { + that.props.onLoggedIn(); + } + /*dis.dispatch({ 'action': 'logged_in' - }); + });*/ }, function(error) { that.setStep("stage_m.login.password"); that.setState({errorText: 'Login failed.'});