From b56661c72e835f62547067de4c7a7bdc5b9668ab Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 22 Mar 2013 22:20:17 +0100 Subject: [PATCH] fix markAsRead propagation --- src/main/webapp/js/controllers.js | 26 ++++++++++++-------------- src/main/webapp/templates/feeds.html | 28 +++++++++++++--------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 93d919e5..6078caf0 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -55,27 +55,25 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location, $location.path('/feeds/view/category/' + id); }; - var markAsRead = function(children, entry, read) { - for ( var i = 0; i < children.length; i++) { - var child = children[i]; - if (child.children) { - markAsRead(child.children, entry, read); + var markAsRead = function(node, entry, read) { + if (node.children) { + for ( var i = 0; i < node.children.length; i++) { + markAsRead(node.children[i], entry, read); } - if (child.feeds) { - for ( var j = 0; j < child.feeds.length; j++) { - var feed = child.feeds[j]; - if (feed.id == entry.feedId) { - var c = read ? -1 : 1; - feed.unread = feed.unread + c; - } + } + if (node.feeds) { + for ( var i = 0; i < node.feeds.length; i++) { + var feed = node.feeds[i]; + if (feed.id == entry.feedId) { + var c = read ? -1 : 1; + feed.unread = feed.unread + c; } } } }; $scope.$on('markAsRead', function(event, args) { - console.log(args.entry) - markAsRead($scope.root.children, args.entry, args.read) + markAsRead($scope.root, args.entry, args.read) }); }); diff --git a/src/main/webapp/templates/feeds.html b/src/main/webapp/templates/feeds.html index c92b4f0a..642dca4a 100644 --- a/src/main/webapp/templates/feeds.html +++ b/src/main/webapp/templates/feeds.html @@ -3,28 +3,26 @@
    - - - - - - - - +
- {{entryList.name}} » + {{entryList.name}} »
\ No newline at end of file