make main refetch cycle asynchronous

master
Andrew Dolgov 17 years ago
parent 1341ea0dbe
commit c20fd46335

@ -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,28 +67,24 @@ function dlg_frefresh_callback() {
} }
} }
function refetch_callback() { function refetch_callback2(transport) {
if (xmlhttp_ctr.readyState == 4) { try {
try {
var date = new Date();
last_refetch = date.getTime() / 1000; var date = new Date();
parse_counters_reply(xmlhttp_ctr, true); parse_counters_reply(transport, true);
debug("refetch_callback: done"); debug("refetch_callback2: done");
if (!daemon_enabled && !daemon_refresh_only) { if (!daemon_enabled && !daemon_refresh_only) {
notify_info("All feeds updated."); notify_info("All feeds updated.");
updateTitle("");
} else {
//notify("");
}
} catch (e) {
exception_error("refetch_callback", e);
updateTitle(""); updateTitle("");
} else {
//notify("");
} }
} catch (e) {
exception_error("refetch_callback", e);
updateTitle("");
} }
} }
@ -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) {

Loading…
Cancel
Save