From e1aca588b5c19138562aeeeadd4129e862bb09f2 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 22 Jul 2015 09:43:40 +0100 Subject: [PATCH] Clear local storage *before* creating the client, Otherwise we will blow away anything that the client tried to persist after it was created --- src/MatrixClientPeg.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 322b70f48c..36ccd0a7dc 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -76,10 +76,16 @@ module.exports = { }, replaceUsingAccessToken: function(hs_url, is_url, user_id, access_token) { - createClient(hs_url, is_url, user_id, access_token); if (localStorage) { try { localStorage.clear(); + } catch (e) { + console.warn("Error using local storage"); + } + } + createClient(hs_url, is_url, user_id, access_token); + if (localStorage) { + try { localStorage.setItem("mx_hs_url", hs_url); localStorage.setItem("mx_is_url", is_url); localStorage.setItem("mx_user_id", user_id);