From: Andrew Dolgov Date: Sun, 3 Jun 2012 16:02:51 +0000 (+0400) Subject: experimental tweak to not mark articles newer than last one loaded in the buffer... X-Git-Tag: 1.6.0~222 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=184f51952c2c0bdcafab9d22a9367facbea28376;p=tt-rss.git experimental tweak to not mark articles newer than last one loaded in the buffer as read --- diff --git a/classes/rpc.php b/classes/rpc.php index a5e32d47..86128ccf 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -646,8 +646,9 @@ class RPC extends Protected_Handler { function catchupFeed() { $feed_id = db_escape_string($_REQUEST['feed_id']); $is_cat = db_escape_string($_REQUEST['is_cat']) == "true"; + $max_id = (int) db_escape_string($_REQUEST['max_id']); - catchup_feed($this->link, $feed_id, $is_cat); + catchup_feed($this->link, $feed_id, $is_cat, false, $max_id); print json_encode(array("message" => "UPDATE_COUNTERS")); } diff --git a/include/functions.php b/include/functions.php index d11d62d2..346396ed 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1320,12 +1320,14 @@ } } - function catchup_feed($link, $feed, $cat_view, $owner_uid = false) { + function catchup_feed($link, $feed, $cat_view, $owner_uid = false, $max_id = false) { if (!$owner_uid) $owner_uid = $_SESSION['uid']; //if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { + $ref_check_qpart = ($max_id) ? "ref_id <= '$max_id'" : "true"; + if (is_numeric($feed)) { if ($cat_view) { @@ -1346,34 +1348,43 @@ db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE feed_id = '$tmp_feed' AND owner_uid = $owner_uid"); + WHERE feed_id = '$tmp_feed' + AND $ref_check_qpart + AND owner_uid = $owner_uid"); } } else if ($feed == -2) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*) FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0 - AND unread = true AND owner_uid = $owner_uid"); + AND $ref_check_qpart + AND unread = true AND owner_uid = $owner_uid"); } } else if ($feed > 0) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE feed_id = '$feed' AND owner_uid = $owner_uid"); + WHERE feed_id = '$feed' + AND $ref_check_qpart + AND owner_uid = $owner_uid"); } else if ($feed < 0 && $feed > -10) { // special, like starred if ($feed == -1) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE marked = true AND owner_uid = $owner_uid"); + WHERE marked = true + AND $ref_check_qpart + AND owner_uid = $owner_uid"); } if ($feed == -2) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE published = true AND owner_uid = $owner_uid"); + WHERE published = true + AND $ref_check_qpart + AND owner_uid = $owner_uid"); } if ($feed == -3) { @@ -1405,7 +1416,7 @@ if ($feed == -4) { db_query($link, "UPDATE ttrss_user_entries SET unread = false,last_read = NOW() - WHERE owner_uid = $owner_uid"); + WHERE $ref_check_qpart AND owner_uid = $owner_uid"); } } else if ($feed < -10) { // label @@ -1415,6 +1426,7 @@ db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2 SET unread = false, last_read = NOW() WHERE label_id = '$label_id' AND unread = true + AND $ref_check_qpart AND owner_uid = '$owner_uid' AND ref_id = article_id"); } @@ -1432,7 +1444,7 @@ while ($line = db_fetch_assoc($result)) { db_query($link, "UPDATE ttrss_user_entries SET unread = false, last_read = NOW() - WHERE int_id = " . $line["post_int_id"]); + WHERE $ref_check_qpart AND int_id = " . $line["post_int_id"]); } db_query($link, "COMMIT"); } diff --git a/js/feedlist.js b/js/feedlist.js index a2a24d0e..4341a5d8 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -480,6 +480,8 @@ function catchupFeedInGroup(id) { function catchupFeed(feed, is_cat) { try { + if (is_cat == undefined) is_cat = false; + var str = __("Mark all articles in %s as read?"); var fn = getFeedName(feed, is_cat); @@ -489,8 +491,22 @@ function catchupFeed(feed, is_cat) { return; } + var max_id = 0; + + if (feed = getActiveFeedId() && is_cat == activeFeedIsCat()) { + $$("#headlines-frame > div[id*=RROW]").each( + function(child) { + var id = parseInt(child.id.replace("RROW-", "")); + + if (id > max_id) max_id = id; + } + ); + } + var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" + - feed + "&is_cat=" + is_cat; + feed + "&is_cat=" + is_cat + "&max_id=" + max_id; + + console.log(catchup_query); notify_progress("Loading, please wait...", true);