make main refetch cycle asynchronous

This commit is contained in:
Andrew Dolgov 2007-08-24 05:12:23 +01:00
parent 1341ea0dbe
commit c20fd46335
1 changed files with 19 additions and 39 deletions

View File

@ -9,7 +9,6 @@ var daemon_enabled = false;
var daemon_refresh_only = false; var daemon_refresh_only = false;
var _qfd_deleted_feed = 0; var _qfd_deleted_feed = 0;
var firsttime_update = true; var firsttime_update = true;
var last_refetch = 0;
var cookie_lifetime = 0; var cookie_lifetime = 0;
var active_feed_id = 0; var active_feed_id = 0;
var active_feed_is_cat = false; var active_feed_is_cat = false;
@ -17,7 +16,6 @@ var number_of_feeds = 0;
var sanity_check_done = false; var sanity_check_done = false;
var xmlhttp = Ajax.getTransport(); var xmlhttp = Ajax.getTransport();
var xmlhttp_ctr = Ajax.getTransport();
var init_params = new Object(); var init_params = new Object();
@ -69,17 +67,14 @@ function dlg_frefresh_callback() {
} }
} }
function refetch_callback() { function refetch_callback2(transport) {
if (xmlhttp_ctr.readyState == 4) {
try { try {
var date = new Date(); var date = new Date();
last_refetch = date.getTime() / 1000; parse_counters_reply(transport, true);
parse_counters_reply(xmlhttp_ctr, true); debug("refetch_callback2: done");
debug("refetch_callback: done");
if (!daemon_enabled && !daemon_refresh_only) { if (!daemon_enabled && !daemon_refresh_only) {
notify_info("All feeds updated."); notify_info("All feeds updated.");
@ -92,7 +87,6 @@ function refetch_callback() {
updateTitle(""); updateTitle("");
} }
} }
}
function backend_sanity_check_callback() { function backend_sanity_check_callback() {
@ -154,9 +148,10 @@ function backend_sanity_check_callback() {
function scheduleFeedUpdate(force) { function scheduleFeedUpdate(force) {
debug("in scheduleFeedUpdate");
if (!daemon_enabled && !daemon_refresh_only) { if (!daemon_enabled && !daemon_refresh_only) {
notify_progress("Updating feeds, please wait.", true); notify_progress("Updating feeds...", true);
updateTitle("Updating");
} }
var query_str = "backend.php?op=rpc&subop="; var query_str = "backend.php?op=rpc&subop=";
@ -183,31 +178,16 @@ function scheduleFeedUpdate(force) {
query_str = query_str + "&omode=" + omode; query_str = query_str + "&omode=" + omode;
query_str = query_str + "&uctr=" + global_unread; query_str = query_str + "&uctr=" + global_unread;
debug("in scheduleFeedUpdate");
var date = new Date(); var date = new Date();
var timestamp = Math.round(date.getTime() / 1000); var timestamp = Math.round(date.getTime() / 1000);
query_str = query_str + "&ts=" + timestamp query_str = query_str + "&ts=" + timestamp
if (!xmlhttp_ready(xmlhttp_ctr) && last_refetch < date.getTime() / 1000 - 60) {
debug("<b>xmlhttp seems to be stuck, aborting</b>");
xmlhttp_ctr.abort();
if (is_safari()) {
xmlhttp_ctr = Ajax.getTransport();
}
}
debug("REFETCH query: " + query_str); debug("REFETCH query: " + query_str);
if (xmlhttp_ready(xmlhttp_ctr)) { new Ajax.Request(query_str, {
xmlhttp_ctr.open("GET", query_str, true); onComplete: function(transport) {
xmlhttp_ctr.onreadystatechange=refetch_callback; refetch_callback2(transport);
xmlhttp_ctr.send(null); } });
} else {
debug("xmlhttp_ctr busy");
//printLockingError();
}
} }
function updateFeedList(silent, fetch) { function updateFeedList(silent, fetch) {