Mercurial > bugzilla-dashboard
diff js/modules/app.js @ 72:0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 18:21:34 -0700 |
parents | 4ec651cc606e |
children | 1cd66cabe153 |
line wrap: on
line diff
--- a/js/modules/app.js Sun Apr 25 17:55:54 2010 -0700 +++ b/js/modules/app.js Sun Apr 25 18:21:34 2010 -0700 @@ -42,49 +42,8 @@ }; }; -Require.modules["app/bugzilla-serial"] = function(exports, require) { - const EVENTS = ["abort", "error", "load"]; - +Require.modules["app/bugzilla-auth"] = function(exports, require) { var myproto = require("bugzilla"); - var active = null; - var queue = []; - - function enqueue(bugzilla, options) { - queue.push({bugzilla: bugzilla, options: options}); - if (!active) - activateNextInQueue(); - } - - function activateNextInQueue() { - if (queue.length) { - var entry = queue.splice(0, 1)[0]; - var xhr = myproto.ajax.call(entry.bugzilla, entry.options); - EVENTS.forEach(function(name) { - xhr.addEventListener(name, onDone, false); - }); - active = xhr; - } else - active = null; - } - - function onDone(event) { - var xhr = event.target; - EVENTS.forEach(function(name) { - xhr.removeEventListener(name, onDone, false); - }); - activateNextInQueue(); - }; - - exports.Bugzilla = { - ajax: function ajax(options) { - enqueue(this, options); - }, - __proto__: myproto - }; -}; - -Require.modules["app/bugzilla-auth"] = function(exports, require) { - var myproto = require("app/bugzilla-serial").Bugzilla; exports.Bugzilla = { ajax: function ajax(options) { @@ -424,6 +383,7 @@ var dateUtils = require("date-utils"); var bugzilla = require("app/bugzilla-auth").Bugzilla; var window = require("window"); + var xhrQueue = require("xhr/queue").create(); function sortByLastChanged(bugs) { var lctimes = {}; @@ -532,12 +492,16 @@ $(selector).find("h2").addClass("loading"); - bugzilla.search(newTerms, - function(response) { - cache.set(cacheKey, response.bugs); - showBugs($(selector), response.bugs); - $(selector).find("h2").removeClass("loading"); - }); + xhrQueue.enqueue( + function() { + return bugzilla.search( + newTerms, + function(response) { + cache.set(cacheKey, response.bugs); + showBugs($(selector), response.bugs); + $(selector).find("h2").removeClass("loading"); + }); + }); } function timeAgo(ms) { @@ -555,6 +519,8 @@ }; function update(myUsername) { + xhrQueue.clear(); + report("#code-reviews", myUsername, {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], flag_DOT_requestee: myUsername});