From 048701937d52423fc4218652597d321153acd72c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 11 Feb 2009 13:35:24 +0300 Subject: [PATCH] offline: add progress indicator; tweak download intervals and amount of articles --- images/offline-sync.gif | Bin 0 -> 847 bytes modules/backend-rpc.php | 10 +++++----- offline.js | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100755 images/offline-sync.gif diff --git a/images/offline-sync.gif b/images/offline-sync.gif new file mode 100755 index 0000000000000000000000000000000000000000..71932f968b8d90d953946534edd1ea52738fc740 GIT binary patch literal 847 zcmZ?wbhEHb6krfw_`<;O|Nno6GYmie{IIxg(eku~?JS$xWwmSHuB~{xLhOQA+2gXb z2Wd}!Jel!w#<5SwJZ^b}-3enL1t|WLaxO|uEJ;mKD9+=1vF0aKewN2NU*bGfUA+70W%{|NC#vK$dL@J0SXFzDVg(@8i?d5YPBS+T02AJ z*hDGQh7W8vI~t;US!|dxTLUHvv@&+KF6vvOsng&Y^<$Ar(uZ9hlO|ZStT0uRt>`q( zRrsVZURxz7(zDPC;End!cWksmvOvsie0DY+Zd4k3*5f3e{BLO0ux=Y#(-y1h_ zSvj9J^xopp()5tcLvM!4&5e}|90L0;o?*R_#jV#E?&5HVFOp%Afd{8ptBygR(-p41 zYyq!lZ+SxPP0N{CYE-g$V>J1Bx?z?wBU>5-3DyRMDNKeUM;%r)JIk@H5kHpQ-86?$ z(dkKoJwxMmrhOBXU7IYboB|^nl6U7WD&rPXTBz{y(Bg!~gf`w#w`Gz=cO?0i7QEK{ zoc6x~W(^CnH6XtMV{e56kE@};p_3B1u@c93N_g~KXuF}oF3`nd!ldwALq}qnn_{8| zLqzZlj>cTmC0iMjTs*e0F|68|n54tir`k|pES7vkd4u{7-Zx6@CT8XVYFZKc4H`YY zDlkh~ku8mfTIvDx7{@XP6NW>ZjyWoMPUP4yYheP1U0y4zr-4d`M6aB;`6gZu9rlBr zx+Tq8P0g-SA_7Ye>t0M)(UEX~>8F5UCx^s_=??vT&gK~$`i3lNtTCG1J!*;!)}Z7G F1_1QF2;2Yw literal 0 HcmV?d00001 diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 6bae380a1..3a63c6094 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -516,14 +516,14 @@ 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 ""; @@ -653,7 +653,7 @@ if ($stage > 0) { print ""; - $limit = 50; + $limit = 200; $skip = $limit*($stage-1); print ""; @@ -669,7 +669,7 @@ } 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") { diff --git a/offline.js b/offline.js index cced40943..4b2114560 100644 --- a/offline.js +++ b/offline.js @@ -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("update_offline_data: done " + stage + " HSD: " + has_sync_data + ""); } 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) {