From 28022534f70ac9e9a4d0e7496447613d0fe0fe86 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 20 Jul 2015 14:19:13 +0100 Subject: [PATCH] Fix the client-peg clean up to match the changes vector has made to the sdk --- src/MatrixClientPeg.js | 4 ++++ src/controllers/pages/MatrixChat.js | 2 +- src/controllers/templates/Login.js | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 6b36e67e..1acd2a70 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -49,6 +49,10 @@ module.exports = { return matrixClient; }, + unset: function() { + matrixClient = null; + }, + replaceUsingUrls: function(hs_url, is_url) { matrixClient = Matrix.createClient({ baseUrl: hs_url, diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index 48c55fe0..42aa3a52 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -90,7 +90,7 @@ module.exports = { } Notifier.stop(); MatrixClientPeg.get().removeAllListeners(); - MatrixClientPeg.replace(null); + MatrixClientPeg.unset(); break; case 'start_registration': if (this.state.logged_in) return; diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index 1cfec18d..37a95785 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -76,11 +76,11 @@ module.exports = { 'password': formVals.password }).done(function(data) { MatrixClientPeg.replaceUsingAccessToken( - that.state.hs_url, that.state.is_url, + self.state.hs_url, self.state.is_url, data.user_id, data.access_token ); - if (that.props.onLoggedIn) { - that.props.onLoggedIn(); + if (self.props.onLoggedIn) { + self.props.onLoggedIn(); } }, function(error) { self.setStep("stage_m.login.password");