From 5223e6ed30d785ed13a9bb9c21ddf52c3f92cc2a Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 11 Jan 2016 16:08:54 -0800 Subject: [PATCH] Stop ask to re-link forever Clear the registration flag when we detect that our credentials have been invalidated, but retain the knowledge that we've been registered before, so as to preserve post-first-install behaviors like skipping the introductory install screens, and accessing the main ui. Fix #541 // FREEBIE --- js/background.js | 6 ++++-- js/chromium.js | 8 +++++++- js/options.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/js/background.js b/js/background.js index 8a15b4c6f..f4d5510e4 100644 --- a/js/background.js +++ b/js/background.js @@ -40,9 +40,10 @@ extension.onLaunched(function() { console.log('extension launched'); storage.onready(function() { - if (textsecure.registration.isDone()) { + if (textsecure.registration.everDone()) { openInbox(); - } else { + } + if (!textsecure.registration.isDone()) { extension.install(); } }); @@ -180,6 +181,7 @@ console.log(e.stack); if (e.name === 'HTTPError' && (e.code == 401 || e.code == 403)) { + textsecure.registration.remove(); extension.install(); return; } diff --git a/js/chromium.js b/js/chromium.js index 47b2c0856..813f2d101 100644 --- a/js/chromium.js +++ b/js/chromium.js @@ -165,13 +165,19 @@ window.textsecure = window.textsecure || {}; window.textsecure.registration = { done: function () { + storage.put("chromiumRegistrationDoneEver", ""); storage.put("chromiumRegistrationDone", ""); extension.trigger('registration_done'); }, - isDone: function () { return storage.get("chromiumRegistrationDone") === ""; }, + everDone: function() { + return storage.get("chromiumRegistrationDoneEver") === ""; + }, + remove: function() { + storage.remove("chromiumRegistrationDone"); + }, }; extension.install = function(mode) { diff --git a/js/options.js b/js/options.js index eff492246..dd7c6dd58 100644 --- a/js/options.js +++ b/js/options.js @@ -21,7 +21,7 @@ el: $('#install'), deviceName: deviceName }); - if (bg.textsecure.registration.isDone()) { + if (bg.textsecure.registration.everDone()) { view.selectStep(3); } view.$el.show();