]> git.wh0rd.org Git - tt-rss.git/commitdiff
fix opening next unread feed on catchup
authorAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 08:25:08 +0000 (11:25 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 08:25:08 +0000 (11:25 +0300)
FeedTree.js
feedlist.js

index 19c32a95f6d412d49748332f39f7dd3dc33085cf..76b46601be5a410f11064f3f8f02716540755758 100644 (file)
@@ -52,6 +52,42 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
                if (treeItem)
                        return this.store.setValue(treeItem, key, value);
        },
+       getNextUnreadFeed: function (feed, is_cat) {
+               if (is_cat) {
+                       treeItem = this.store._itemsByIdentity['CAT:' + feed];
+                       items = this.store._arrayOfTopLevelItems;
+               } else {
+                       treeItem = this.store._itemsByIdentity['FEED:' + feed];
+                       items = this.store._arrayOfAllItems;
+               }
+
+               for (var i = 0; i < items.length; i++) {
+                       if (items[i] == treeItem) {
+
+                               for (j = i+1; j < items.length; j++) {
+                                       var unread = this.store.getValue(items[j], 'unread');
+                                       var id = this.store.getValue(items[j], 'id');
+
+                                       if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j];
+                               }
+
+                               for (j = 0; j < i; j++) {
+                                       var unread = this.store.getValue(items[j], 'unread');
+                                       var id = this.store.getValue(items[j], 'id');
+
+                                       if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j];
+                               }
+                       }
+               }
+               
+               return null;
+       },
+       hasCats: function() {
+               if (this.store && this.store._itemsByIdentity)
+                       return this.store._itemsByIdentity['CAT:-1'] != undefined;
+               else
+                       return false;
+       },
 });
 
 dojo.declare("fox.FeedTree", dijit.Tree, {
@@ -144,10 +180,7 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
                return false;
        },
        hasCats: function() {
-               if (this.model.store && this.model.store._itemsByIdentity)
-                       return this.model.store._itemsByIdentity['CAT:-1'] != undefined;
-               else
-                       return false;
+               return this.model.hasCats();
        },
        hideRead: function (hide, show_special) {
                if (this.hasCats()) {
index bd1c85722733381c9df128f041c06a7da696a630..d694b9be7975fb12714cfed1e4d052e0353300c9 100644 (file)
@@ -115,7 +115,14 @@ function viewfeed(feed, subop, is_cat, offset) {
                        var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
 
                        if (show_next_feed) {
-                               // TODO: implement show_next_feed handling
+                               var tree = dijit.byId("feedTree");
+                               var nuf = tree.model.getNextUnreadFeed(feed, is_cat);
+
+                               if (nuf) {
+                                       var nuf_id = tree.model.store.getValue(nuf, 'bare_id');
+
+                                       query = query + "&nuf=" + param_escape(nuf_id);
+                               }
                        }
                }