From 4093021f974add4567acc426e7e329670de3db3d Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 13 Jun 2013 14:32:08 -0400 Subject: [PATCH] Stop polling for gravatar changes after the first update. This is essentially a bug fix. It was pretty clear that the original author intended to stop polling once the gravatar was updated, but they checked for the updated flag before the callback completed, instead of inside the success callback, so it wouldn't stop polling regardless of the update. (imported from commit 7998c6890a26a008810b8a6d8e7998a53c6e175d) --- zephyr/static/js/ui.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index f55cdd36bd..b1f14ed15b 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -579,8 +579,10 @@ function update_gravatars() { } function poll_for_gravatar_update(start_time, url) { - var updated = false; - + // Give users 5 minutes to update their picture on gravatar.com, + // during which we try to auto-update their image on our site. If + // they take longer than that, we'll update when they press the + // save button. $.ajax({ type: "HEAD", url: url, @@ -589,20 +591,17 @@ function poll_for_gravatar_update(start_time, url) { success: function (resp, statusText, xhr) { if (new Date(xhr.getResponseHeader('Last-Modified')) > start_time) { update_gravatars(); - updated = true; + } + else { + if (($.now() - start_time) < 1000 * 60 * 5) { + setTimeout(function () { + poll_for_gravatar_update(start_time, url); + }, 1500); + } } } }); - // Give users 5 minutes to update their picture on gravatar.com, - // during which we try to auto-update their image on our site. If - // they take longer than that, we'll update when they press the - // save button. - if (!updated && (($.now() - start_time) < 1000 * 60 * 5)) { - setTimeout(function () { - poll_for_gravatar_update(start_time, url); - }, 1500); - } } exports.get_gravatar_stamp = function () {