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)
This commit is contained in:
Steve Howell 2013-06-13 14:32:08 -04:00
parent cbbca8319b
commit 4093021f97
1 changed files with 11 additions and 12 deletions

View File

@ -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 () {