From 9133752e990fefab6eaad596d4a32427bd8890db Mon Sep 17 00:00:00 2001 From: Danny Amey Date: Thu, 17 May 2012 12:28:31 +0100 Subject: [PATCH] prevent UI update during assertion verify - closes mozilla/123done#18 --- packages/123done/static/js/123done.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/123done/static/js/123done.js b/packages/123done/static/js/123done.js index c827060c3f..2f8239cf7b 100644 --- a/packages/123done/static/js/123done.js +++ b/packages/123done/static/js/123done.js @@ -8,6 +8,8 @@ $(document).ready(function() { window.loggedInEmail = null; + var loginAssertion = null; + // enable experimental API features if (!navigator.id.request) { navigator.id.request = navigator.id.experimental.request; @@ -61,17 +63,21 @@ $(document).ready(function() { loggedInEmail: loggedInEmail, // onlogin will be called any time the user logs in onlogin: function(assertion) { + loginAssertion = assertion; + // display spinner $("ul.loginarea li").css('display', 'none'); $(".loginarea .loading").css('display', 'block'); verifyAssertion(assertion, function(r) { loggedInEmail = r.email; + loginAssertion = null; updateUI(loggedInEmail); State.merge(); }, function(err) { alert("failed to verify assertion: " + err); loggedInEmail = null; + loginAssertion = null; updateUI(loggedInEmail); }); }, @@ -95,8 +101,11 @@ $(document).ready(function() { // onready will be called as soon as persona has loaded, at this // point we can display our login buttons. onready: function() { - updateUI(loggedInEmail); - + // Only update the UI if no assertion is being verified + if (null === loginAssertion) { + updateUI(loggedInEmail); + } + // display current saved state State.load(); }