Just use Lifecycle.setLoggedIn

This commit is contained in:
David Baker 2016-08-02 19:02:07 +01:00
parent d74a8e405d
commit 0c61c52480

View file

@ -162,7 +162,7 @@ module.exports = React.createClass({
this.props.startingQueryParams.guest_access_token) this.props.startingQueryParams.guest_access_token)
{ {
this._autoRegisterAsGuest = false; this._autoRegisterAsGuest = false;
this._onHaveCredentials({ Lifecycle.setLoggedIn({
userId: this.props.startingQueryParams.guest_user_id, userId: this.props.startingQueryParams.guest_user_id,
accessToken: this.props.startingQueryParams.guest_access_token, accessToken: this.props.startingQueryParams.guest_access_token,
homeserverUrl: this.getDefaultHsUrl(), homeserverUrl: this.getDefaultHsUrl(),
@ -235,7 +235,7 @@ module.exports = React.createClass({
MatrixClientPeg.get().registerGuest().done(function(creds) { MatrixClientPeg.get().registerGuest().done(function(creds) {
console.log("Registered as guest: %s", creds.user_id); console.log("Registered as guest: %s", creds.user_id);
self._setAutoRegisterAsGuest(false); self._setAutoRegisterAsGuest(false);
self._onHaveCredentials({ Lifecycle.setLoggedIn({
userId: creds.user_id, userId: creds.user_id,
accessToken: creds.access_token, accessToken: creds.access_token,
homeserverUrl: hsUrl, homeserverUrl: hsUrl,
@ -577,11 +577,6 @@ module.exports = React.createClass({
this.scrollStateMap[roomId] = state; this.scrollStateMap[roomId] = state;
}, },
_onHaveCredentials: function(credentials) {
credentials.guest = Boolean(credentials.guest);
Lifecycle.setLoggedIn(credentials);
},
_onLoggedIn: function(credentials) { _onLoggedIn: function(credentials) {
this.guestCreds = null; this.guestCreds = null;
this.setState({ this.setState({
@ -909,13 +904,13 @@ module.exports = React.createClass({
onReturnToGuestClick: function() { onReturnToGuestClick: function() {
// reanimate our guest login // reanimate our guest login
if (this.guestCreds) { if (this.guestCreds) {
this._onHaveCredentials(this.guestCreds); Lifecycle.setLoggedIn(this.guestCreds);
this.guestCreds = null; this.guestCreds = null;
} }
}, },
onRegistered: function(credentials) { onRegistered: function(credentials) {
this._onHaveCredentials(credentials); Lifecycle.setLoggedIn(credentials);
// do post-registration stuff // do post-registration stuff
// This now goes straight to user settings // This now goes straight to user settings
// We use _setPage since if we wait for // We use _setPage since if we wait for
@ -1137,7 +1132,7 @@ module.exports = React.createClass({
} else { } else {
return ( return (
<Login <Login
onLoggedIn={this._onHaveCredentials} onLoggedIn={Lifecycle.setLoggedIn}
onRegisterClick={this.onRegisterClick} onRegisterClick={this.onRegisterClick}
defaultHsUrl={this.getDefaultHsUrl()} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.getDefaultIsUrl()} defaultIsUrl={this.getDefaultIsUrl()}