]> git.wh0rd.org - tt-rss.git/blobdiff - js/feedlist.js
set error report url to https
[tt-rss.git] / js / feedlist.js
index 232cf0be1a8987d1e59e55e2f975791b27b22e2c..6d37377a45b327868bf4f4b1f838408d5927e400 100644 (file)
@@ -13,6 +13,10 @@ var _counters_prev = [];
        return false;
 }*/
 
+function resetCounterCache() {
+       _counters_prev = [];
+}
+
 function loadMoreHeadlines() {
        try {
                console.log("loadMoreHeadlines");
@@ -254,15 +258,41 @@ function request_counters(force) {
        }
 }
 
+// NOTE: this implementation is incomplete
+// for general objects but good enough for counters
+// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
+function counter_is_equal(a, b) {
+       // Create arrays of property names
+       var aProps = Object.getOwnPropertyNames(a);
+       var bProps = Object.getOwnPropertyNames(b);
+
+       // If number of properties is different,
+       // objects are not equivalent
+       if (aProps.length != bProps.length) {
+               return false;
+       }
+
+       for (var i = 0; i < aProps.length; i++) {
+               var propName = aProps[i];
+
+               // If values of same property are not equal,
+               // objects are not equivalent
+               if (a[propName] !== b[propName]) {
+                       return false;
+               }
+       }
+
+       // If we made it this far, objects
+       // are considered equivalent
+       return true;
+}
+
+
 function parse_counters(elems) {
        try {
                for (var l = 0; l < elems.length; l++) {
 
-                       if (_counters_prev[l]  &&
-                               _counters_prev[l].id == elems[l].id &&
-                               _counters_prev[l].updated == elems[l].updated &&
-                               _counters_prev[l].counter == elems[l].counter) {
-
+                       if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) {
                                continue;
                        }
 
@@ -281,13 +311,13 @@ function parse_counters(elems) {
                        }
 
                        if (id == "subscribed-feeds") {
-                               feeds_found = ctr;
+                               /* feeds_found = ctr; */
                                continue;
                        }
 
-                       if (getFeedUnread(id, (kind == "cat")) != ctr ||
+                       /*if (getFeedUnread(id, (kind == "cat")) != ctr ||
                                        (kind == "cat")) {
-                       }
+                       }*/
 
                        setFeedUnread(id, (kind == "cat"), ctr);
                        setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr);