]> git.wh0rd.org - tt-rss.git/blobdiff - feedlist.js
remove xml from getAllCounters rpc call, use pure JSON
[tt-rss.git] / feedlist.js
index 1f4819a35a5d94030d0696e3cbb1a521b4699f1d..b475b9c5509dffdcc4b84ff69b1c98b999066544 100644 (file)
@@ -1,6 +1,7 @@
 var _feed_cur_page = 0;
 var _infscroll_disable = 0;
 var _infscroll_request_sent = 0;
+var _search_query = false;
 
 var counter_timeout_id = false;
 
@@ -29,6 +30,7 @@ function viewNextFeedPage() {
 function viewfeed(feed, subop, is_cat, offset) {
        try {
                if (is_cat == undefined) is_cat = false;
+               if (subop == undefined) subop = '';
 
 //             if (!offset) page_offset = 0;
 
@@ -80,9 +82,7 @@ function viewfeed(feed, subop, is_cat, offset) {
                        _infscroll_request_sent = timestamp;                    
                }
 
-               enableHotkeys();
                hideAuxDlg();
-               closeInfoBox();
 
                Form.enable("main_toolbar_form");
 
@@ -99,12 +99,10 @@ function viewfeed(feed, subop, is_cat, offset) {
                var query = "?op=viewfeed&feed=" + feed + "&" +
                        toolbar_query + "&subop=" + param_escape(subop);
 
-               if ($("search_form")) {
-                       var search_query = Form.serialize("search_form");
-                       query = query + "&" + search_query;
-                       $("search_form").query.value = "";
-                       closeInfoBox(true);
+               if (_search_query) {
                        force_nocache = true;
+                       query = query + "&" + _search_query;
+                       _search_query = false;
                }
 
 //             console.log("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
@@ -114,7 +112,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);
+                               }
                        }
                }
 
@@ -135,8 +140,6 @@ function viewfeed(feed, subop, is_cat, offset) {
 
                console.log(query);
 
-               var container = $("headlinesInnerContainer");
-
                var unread_ctr = -1;
                
                if (!is_cat) unread_ctr = getFeedUnread(feed);
@@ -210,6 +213,8 @@ function feedlist_init() {
 
                hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
 
+               setTimeout("timeout()", 5000);
+
        } catch (e) {
                exception_error("feedlist/init", e);
        }
@@ -227,7 +232,7 @@ function request_counters_real() {
                        parameters: query,
                        onComplete: function(transport) { 
                                try {
-                                       handle_rpc_reply(transport);
+                                       handle_rpc_json(transport);
                                } catch (e) {
                                        exception_error("viewfeed/getcounters", e);
                                }
@@ -281,13 +286,11 @@ function displayNewContentPrompt(id) {
        }
 }
 
-function parse_counters(reply, scheduled_call) {
+function parse_counters(elems, scheduled_call) {
        try {
 
                var feeds_found = 0;
 
-               var elems = JSON.parse(reply.firstChild.nodeValue);
-
                for (var l = 0; l < elems.length; l++) {
 
                        var id = elems[l].id
@@ -297,7 +300,7 @@ function parse_counters(reply, scheduled_call) {
                        var has_img = elems[l].has_img;
                        var updated = elems[l].updated;
                        var title = elems[l].title;
-       
+
                        if (id == "global-unread") {
                                global_unread = ctr;
                                updateTitle();
@@ -311,14 +314,17 @@ function parse_counters(reply, scheduled_call) {
 
                        var treeItem;
 
-                       if (id == getActiveFeedId() && ctr > getFeedUnread(id) && scheduled_call) {
+                       // TODO: enable new content notification for categories
+
+                       if (!activeFeedIsCat() && id == getActiveFeedId() 
+                                       && ctr > getFeedUnread(id) && scheduled_call) {
                                displayNewContentPrompt(id);
                        }
 
                        setFeedUnread(id, (kind == "cat"), ctr);
 
                        if (kind != "cat") {
-                               //setFeedValue(id, false, 'error', error);
+                               setFeedValue(id, false, 'error', error);
                                setFeedValue(id, false, 'updated', updated);
 
                                if (id > 0) {
@@ -334,17 +340,6 @@ function parse_counters(reply, scheduled_call) {
        
                hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
 
-               var feeds_stored = number_of_feeds;
-
-               if (feeds_stored != feeds_found) {
-                       number_of_feeds = feeds_found;
-
-                       if (feeds_stored != 0 && feeds_found != 0) {
-                               console.log("Subscribed feed number changed, refreshing feedlist");
-                               setTimeout('updateFeedList()', 50);
-                       }
-               }
-
        } catch (e) {
                exception_error("parse_counters", e);
        }