]> git.wh0rd.org Git - tt-rss.git/commitdiff
offline: add progress indicator; tweak download intervals and amount of articles
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 11 Feb 2009 10:35:24 +0000 (13:35 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 11 Feb 2009 10:35:24 +0000 (13:35 +0300)
images/offline-sync.gif [new file with mode: 0755]
modules/backend-rpc.php
offline.js

diff --git a/images/offline-sync.gif b/images/offline-sync.gif
new file mode 100755 (executable)
index 0000000..71932f9
Binary files /dev/null and b/images/offline-sync.gif differ
index 6bae380a1d9492f9f0d3064f8600da2f8341a299..3a63c6094f8dd6f5eecbda4671633ca91723a444 100644 (file)
 
                if ($subop == "download") {
                        $stage = (int) $_REQUEST["stage"];
-                       $cidt = db_escape_string($_REQUEST["cidt"]);
-                       $cidb = db_escape_string($_REQUEST["cidb"]);
+                       $cidt = (int)db_escape_string($_REQUEST["cidt"]);
+                       $cidb = (int)db_escape_string($_REQUEST["cidb"]);
                        $sync = db_escape_string($_REQUEST["sync"]);
                        //$amount = (int) $_REQUEST["amount"];
                        //$unread_only = db_escape_string($_REQUEST["unread_only"]);
                        //if (!$amount) $amount = 50;
 
-                       $amount = 100;
+                       $amount = 2000;
                        $unread_only = true;
 
                        print "<rpc-reply>";
                        if ($stage > 0) {
                                print "<articles>";
 
-                               $limit = 50;
+                               $limit = 200;
                                $skip = $limit*($stage-1);
 
                                print "<limit value=\"$limit\"/>";
                                        }
 
                                        if ($cidt && $cidb) {
-                                               $cid_qpart =  "(id > $cidt OR id < $cidb) AND ";
+                                               $cid_qpart =  "(ttrss_entries.id > $cidt OR ttrss_entries.id < $cidb) AND ";
                                        }
 
                                        if (DB_TYPE == "pgsql") {
index cced4094377cfbcf9185870824660732ef478ad5..4b2114560700f32d98d3ad8d49fe88154728e67c 100644 (file)
@@ -679,7 +679,7 @@ function offline_download_parse(stage, transport) {
                                                [id, caption, fg_color, bg_color]);
                                }
 
-                               window.setTimeout("update_offline_data("+(stage+1)+")", 10*1000);
+                               window.setTimeout("update_offline_data("+(stage+1)+")", 5*1000);
                        } else {
 
                                var articles = transport.responseXML.getElementsByTagName("article");
@@ -723,13 +723,20 @@ function offline_download_parse(stage, transport) {
                                var has_sync_data = has_local_sync_data();
 
                                if (articles_found >= limit || has_sync_data) {
-                                       window.setTimeout("update_offline_data("+(stage+1)+")", 10*1000);
+                                       window.setTimeout("update_offline_data("+(stage+1)+")", 5*1000);
                                        debug("<b>update_offline_data: done " + stage + " HSD: " + 
                                                has_sync_data + "</b>");
                                } else {
                                        window.setTimeout("update_offline_data(0)", 180*1000);
                                        debug("update_offline_data: finished");
 
+                                       var pic = $("restartOfflinePic");
+
+                                       if (pic) { 
+                                               pic.src = "images/offline.png";
+                                               pic.title = __("Restart in offline mode");
+                                       }                        
+
                                        db.execute("DELETE FROM articles WHERE "+
                                                "updated < DATETIME('NOW', 'localtime', '-31 days')");
 
@@ -737,6 +744,7 @@ function offline_download_parse(stage, transport) {
                        }
 
                        update_local_sync_data();
+               
 
 //                     notify('');
 
@@ -778,6 +786,13 @@ function update_offline_data(stage) {
 
                debug(query + "/" + to_sync);
 
+               var pic = $("restartOfflinePic");
+
+               if (pic) {
+                       pic.src = "images/offline-sync.gif";
+                       pic.title = __("Synchronizing offline data...");
+               }
+
                new Ajax.Request(query, {
                        parameters: to_sync,
                        onComplete: function(transport) {