diff options
Diffstat (limited to 'js/app/services/models/feedmodel.coffee')
-rw-r--r-- | js/app/services/models/feedmodel.coffee | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/js/app/services/models/feedmodel.coffee b/js/app/services/models/feedmodel.coffee index 25cc48d88..838f240c1 100644 --- a/js/app/services/models/feedmodel.coffee +++ b/js/app/services/models/feedmodel.coffee @@ -21,7 +21,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -angular.module('News').factory '_FeedModel', ['_Model', (_Model) -> +angular.module('News').factory '_FeedModel', +['_Model', '_EqualQuery', +(_Model, _EqualQuery) -> class FeedModel extends _Model @@ -35,6 +37,35 @@ angular.module('News').factory '_FeedModel', ['_Model', (_Model) -> super(item) + getUnreadCount: -> + count = 0 + for feed in @getAll() + count += feed.unreadCount + + return count + + + getFeedUnreadCount: (feedId) -> + feed = @getById(feedId) + if angular.isDefined(feed) + return feed.unreadCount + else + return 0 + + + getFolderUnreadCount: (folderId) -> + query = new _EqualQuery('folderId', folderId) + count = 0 + for feed in @get(query) + count += feed.unreadCount + + return count + + + getAllOfFolder: (folderId) -> + query = new _EqualQuery('folderId', folderId) + return @get(query) + return FeedModel ]
\ No newline at end of file |