]> git.wh0rd.org Git - tt-rss.git/commitdiff
make main refetch cycle asynchronous
authorAndrew Dolgov <fox@madoka.spb.ru>
Fri, 24 Aug 2007 04:12:23 +0000 (05:12 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Fri, 24 Aug 2007 04:12:23 +0000 (05:12 +0100)
tt-rss.js

index 0e47069f7f38bf77c818c4e4e0553443452d05c0..3beac28cf56095ac80c3d0a405772df98ddccac1 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -9,7 +9,6 @@ var daemon_enabled = false;
 var daemon_refresh_only = false;
 var _qfd_deleted_feed = 0;
 var firsttime_update = true;
-var last_refetch = 0;
 var cookie_lifetime = 0;
 var active_feed_id = 0;
 var active_feed_is_cat = false;
@@ -17,7 +16,6 @@ var number_of_feeds = 0;
 var sanity_check_done = false;
 
 var xmlhttp = Ajax.getTransport();
-var xmlhttp_ctr = Ajax.getTransport();
 
 var init_params = new Object();
 
@@ -69,28 +67,24 @@ function dlg_frefresh_callback() {
        } 
 }
 
-function refetch_callback() {
-       if (xmlhttp_ctr.readyState == 4) {
-               try {
-
-                       var date = new Date();
+function refetch_callback2(transport) {
+       try {
 
-                       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) {
-                               notify_info("All feeds updated.");
-                               updateTitle("");
-                       } else {
-                               //notify("");
-                       }
-               } catch (e) {
-                       exception_error("refetch_callback", e);
+               if (!daemon_enabled && !daemon_refresh_only) {
+                       notify_info("All feeds updated.");
                        updateTitle("");
+               } else {
+                       //notify("");
                }
+       } catch (e) {
+               exception_error("refetch_callback", e);
+               updateTitle("");
        }
 }
 
@@ -154,9 +148,10 @@ function backend_sanity_check_callback() {
 
 function scheduleFeedUpdate(force) {
 
+       debug("in scheduleFeedUpdate");
+
        if (!daemon_enabled && !daemon_refresh_only) {
-               notify_progress("Updating feeds, please wait.", true);
-               updateTitle("Updating");
+               notify_progress("Updating feeds...", true);
        }
 
        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 + "&uctr=" + global_unread;
 
-       debug("in scheduleFeedUpdate");
-
        var date = new Date();
-
        var timestamp = Math.round(date.getTime() / 1000);
        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);
 
-       if (xmlhttp_ready(xmlhttp_ctr)) {
-               xmlhttp_ctr.open("GET", query_str, true);
-               xmlhttp_ctr.onreadystatechange=refetch_callback;
-               xmlhttp_ctr.send(null);
-       } else {
-               debug("xmlhttp_ctr busy");
-               //printLockingError();
-       }   
+       new Ajax.Request(query_str, {
+               onComplete: function(transport) { 
+                               refetch_callback2(transport); 
+                       } });
 }
 
 function updateFeedList(silent, fetch) {