summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-16 17:24:15 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-16 17:24:15 +0200
commite48be020ad106b16c399c2f4a46741f1f31ea3f3 (patch)
tree30040bb5b12b62dc58ba39c9fe5d7265a7ac3918 /js
parent42ca456a059b7bb228a37a60cd82f141fe927e54 (diff)
fix bug that prevented marking read if the highestitemid was 0 also clientside
Diffstat (limited to 'js')
-rw-r--r--js/app/services/businesslayer/feedbusinesslayer.coffee7
-rw-r--r--js/public/app.js7
-rw-r--r--js/tests/services/businesslayer/feedbusinesslayerSpec.coffee16
3 files changed, 28 insertions, 2 deletions
diff --git a/js/app/services/businesslayer/feedbusinesslayer.coffee b/js/app/services/businesslayer/feedbusinesslayer.coffee
index fcdcc8093..a5176452e 100644
--- a/js/app/services/businesslayer/feedbusinesslayer.coffee
+++ b/js/app/services/businesslayer/feedbusinesslayer.coffee
@@ -32,6 +32,7 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
constructor: (@_showAll, @_feedModel, persistence, activeFeed, feedType,
itemModel, @_newLoading, @_utils) ->
super(activeFeed, persistence, itemModel, feedType.Feed)
+ @_feedType = feedType
getUnreadCount: (feedId) ->
@@ -59,7 +60,11 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
feed = @_feedModel.getById(feedId)
if angular.isDefined(feed)
feed.unreadCount = 0
- highestItemId = @_itemModel.getHighestId()
+ if @_activeFeed.getId() == feedId and
+ @_activeFeed.getType() == @_feedType.Feed
+ highestItemId = @_itemModel.getHighestId()
+ else
+ highestItemId = 0
@_persistence.setFeedRead(feedId, highestItemId)
for item in @_itemModel.getAll()
item.setRead()
diff --git a/js/public/app.js b/js/public/app.js
index 1939c7165..624c4575d 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -703,6 +703,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._newLoading = _newLoading;
this._utils = _utils;
FeedBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed);
+ this._feedType = feedType;
}
FeedBusinessLayer.prototype.getUnreadCount = function(feedId) {
@@ -732,7 +733,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
feed = this._feedModel.getById(feedId);
if (angular.isDefined(feed)) {
feed.unreadCount = 0;
- highestItemId = this._itemModel.getHighestId();
+ if (this._activeFeed.getId() === feedId && this._activeFeed.getType() === this._feedType.Feed) {
+ highestItemId = this._itemModel.getHighestId();
+ } else {
+ highestItemId = 0;
+ }
this._persistence.setFeedRead(feedId, highestItemId);
_ref = this._itemModel.getAll();
_results = [];
diff --git a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
index 8e09e7be9..1b9f009d5 100644
--- a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
+++ b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
@@ -89,6 +89,7 @@ describe 'FeedBusinessLayer', ->
it 'should mark feed as read', =>
+ @ActiveFeed.handle({type: @FeedType.Feed, id: 5})
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
@ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'})
@@ -103,6 +104,21 @@ describe 'FeedBusinessLayer', ->
expect(@ItemModel.getById(2).isRead()).toBeTruthy()
+ it 'should mark feed as read and set 0 if as highest id if its not active',=>
+ @persistence.setFeedRead = jasmine.createSpy('setFeedRead')
+ @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'})
+ @ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'})
+ @ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'})
+ @ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'})
+ @FeedBusinessLayer.markFeedRead(5)
+
+ expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 0)
+ expect(@FeedModel.getById(5).unreadCount).toBe(0)
+ expect(@ItemModel.getById(6).isRead()).toBeTruthy()
+ expect(@ItemModel.getById(3).isRead()).toBeTruthy()
+ expect(@ItemModel.getById(2).isRead()).toBeTruthy()
+
+
it 'should mark all as read', =>
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'})