]> git.wh0rd.org Git - tt-rss.git/commitdiff
experimental tweak to not mark articles newer than last one loaded in the buffer...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 3 Jun 2012 16:02:51 +0000 (20:02 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 3 Jun 2012 16:02:51 +0000 (20:02 +0400)
classes/rpc.php
include/functions.php
js/feedlist.js

index a5e32d47e594d43623823de674b91b2cfef61cd9..86128ccfefc96a4e1647f93e9c117dcb47f01c26 100644 (file)
@@ -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"));
        }
index d11d62d229f97000352d47408025326125736a44..346396ed66be88ddab16f92c5b100572c63eed59 100644 (file)
                }
        }
 
-       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) {
 
 
                                                        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) {
                                        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
                                        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");
 
                                }
                                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");
                        }
index a2a24d0e0bef19304e164e0c9392ee394febb964..4341a5d80cf0c95a194c51a1426a0e84c82bc503 100644 (file)
@@ -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);